Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions Example/SnapSliderFilters.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -329,11 +330,12 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand Down Expand Up @@ -367,9 +369,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -388,7 +391,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -406,7 +409,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
10 changes: 5 additions & 5 deletions SnapSliderFilters/Classes/SNButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ open class SNButton: UIButton {

self.layer.zPosition = 1000
self.adjustsImageWhenHighlighted = false
self.setImage(UIImage(named: name), for: UIControlState())
self.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10)
self.setImage(UIImage(named: name), for: UIControl.State())
self.imageEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)

self.addTarget(self, action: #selector(buttonTouchUpInside), for: .touchUpInside)
self.addTarget(self, action: #selector(buttonPressed), for: .touchDown)
Expand All @@ -114,16 +114,16 @@ open class SNButton: UIButton {
self.action = actionClosure
}

func buttonTouchUpInside() {
@objc func buttonTouchUpInside() {
shouldRunAction=true
buttonReleased()
}

func buttonPressed() {
@objc func buttonPressed() {
buttonState = .bigButton
}

func buttonReleased() {
@objc func buttonReleased() {
buttonState = .smallButton
}
}
19 changes: 6 additions & 13 deletions SnapSliderFilters/Classes/SNFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import UIKit
open class SNFilter: UIImageView {

// Full list of filters available here : https://developer.apple.com/library/tvos/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html
open static let filterNameList = ["No Filter" , "CIPhotoEffectFade", "CIPhotoEffectChrome", "CIPhotoEffectTransfer", "CIPhotoEffectInstant", "CIPhotoEffectMono", "CIPhotoEffectNoir", "CIPhotoEffectProcess", "CIPhotoEffectTonal"]
public static let filterNameList = ["No Filter" , "CIPhotoEffectFade", "CIPhotoEffectChrome", "CIPhotoEffectTransfer", "CIPhotoEffectInstant", "CIPhotoEffectMono", "CIPhotoEffectNoir", "CIPhotoEffectProcess", "CIPhotoEffectTonal"]
open var name:String?
var stickers = [SNSticker]()

public override init(frame: CGRect) {
super.init(frame: frame)
}

public init(frame: CGRect, withImage image:UIImage, withContentMode mode:UIViewContentMode = .scaleAspectFill) {
public init(frame: CGRect, withImage image:UIImage, withContentMode mode:UIView.ContentMode = .scaleAspectFill) {
super.init(frame: frame)
self.contentMode = mode
self.clipsToBounds = true
Expand Down Expand Up @@ -105,20 +105,13 @@ open class SNFilter: UIImageView {
self.stickers.append(sticker)
}

open static func generateFilters(_ originalImage: SNFilter, filters:[String]) -> [SNFilter] {
public static func generateFilters(_ originalImage: SNFilter, filters:[String]) -> [SNFilter] {

var finalFilters = [SNFilter]()

let queue = DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.high)
let syncQueue = DispatchQueue(label: "com.snapsliderfilters.app", attributes: .concurrent)

// Each filter can be generated on a different thread
DispatchQueue.concurrentPerform(iterations: filters.count) { iteration in
let filterComputed = originalImage.applyFilter(filterNamed: filters[iteration])
syncQueue.sync {
finalFilters.append(filterComputed)
return
}
for filter in filters {
let filterComputed = originalImage.applyFilter(filterNamed: filter)
finalFilters.append(filterComputed)
}

return finalFilters
Expand Down
2 changes: 1 addition & 1 deletion SnapSliderFilters/Classes/SNSticker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

open class SNSticker: UIImageView {

public init(frame: CGRect, image:UIImage, withContentMode mode: UIViewContentMode = .scaleAspectFit, atZPosition zIndex:CGFloat? = nil) {
public init(frame: CGRect, image:UIImage, withContentMode mode: UIView.ContentMode = .scaleAspectFit, atZPosition zIndex:CGFloat? = nil) {
super.init(frame: frame)

self.contentMode = mode
Expand Down
12 changes: 6 additions & 6 deletions SnapSliderFilters/Classes/SNTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ open class SNTextField: UITextField {
self.textColor = UIColor.white
self.placeholder = ""
self.font = UIFont.systemFont(ofSize: 16)
self.borderStyle = UITextBorderStyle.none
self.borderStyle = UITextField.BorderStyle.none
self.autocorrectionType = UITextAutocorrectionType.no
self.keyboardType = UIKeyboardType.default
self.returnKeyType = UIReturnKeyType.done
self.clearButtonMode = UITextFieldViewMode.never;
self.contentVerticalAlignment = UIControlContentVerticalAlignment.center
self.clearButtonMode = UITextField.ViewMode.never;
self.contentVerticalAlignment = UIControl.ContentVerticalAlignment.center
self.textAlignment = .center
self.contentHorizontalAlignment = .center
self.delegate = self
Expand Down Expand Up @@ -88,7 +88,7 @@ extension SNTextField: UITextFieldDelegate {
// Limit the text size to the screen width
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let text:NSString = (self.text! as NSString).replacingCharacters(in: range, with: string) as NSString
let contentWidth = text.size(attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: 16.0)]).width
let contentWidth = text.size(withAttributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16.0)]).width
return contentWidth <= (self.frame.width - 20)
}

Expand All @@ -113,7 +113,7 @@ extension SNTextField: UIGestureRecognizerDelegate {
}
}

func handlePan(_ recognizer:UIPanGestureRecognizer) {
@objc func handlePan(_ recognizer:UIPanGestureRecognizer) {

if self.isFirstResponder == true { return }

Expand Down Expand Up @@ -152,7 +152,7 @@ public extension SNTextField {
}

func updatePosition(_ notification: Notification) {
if let keyboardSize = ((notification as NSNotification).userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
if let keyboardSize = ((notification as NSNotification).userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
self.frame.origin.y = self.heightOfScreen - keyboardSize.height - self.frame.size.height
}
}
Expand Down
4 changes: 2 additions & 2 deletions SnapSliderFilters/Classes/SNUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import UIKit

open class SNUtils {

open static let screenSize = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
public static let screenSize = CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)

// Allow you to take a screenshot of the screen
open static func screenShot(_ view: UIView?) -> UIImage? {
public static func screenShot(_ view: UIView?) -> UIImage? {
guard let imageView = view else {
return nil
}
Expand Down