Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.
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
6 changes: 3 additions & 3 deletions Example/editorTest.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
TargetAttributes = {
05D951D01EBB868F00DC2299 = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = B8BKM8368H;
DevelopmentTeam = H4UPLW87TU;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -341,7 +341,7 @@
baseConfigurationReference = F2FE6D2857E80A528393FDF8 /* Pods-editorTest.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = B8BKM8368H;
DEVELOPMENT_TEAM = H4UPLW87TU;
INFOPLIST_FILE = editorTest/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -356,7 +356,7 @@
baseConfigurationReference = 9EEB4D5FF7C66761863E5E50 /* Pods-editorTest.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = B8BKM8368H;
DEVELOPMENT_TEAM = H4UPLW87TU;
INFOPLIST_FILE = editorTest/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
35 changes: 27 additions & 8 deletions Photo Editor/Photo Editor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
isa = PBXGroup;
children = (
056513081EF489B4009EA38F /* PhotoEditorViewController.swift */,
0565133F1EF489CD009EA38F /* PhotoEditor+Drawing.swift */,
056513091EF489B4009EA38F /* StickersViewController.swift */,
0565130A1EF489B4009EA38F /* ColorCollectionViewCell.swift */,
0565130B1EF489B4009EA38F /* ColorsCollectionViewDelegate.swift */,
Expand All @@ -139,7 +140,6 @@
056513181EF489B4009EA38F /* ResizeControl.swift */,
059EA71C1EACB8790072C0FE /* AppDelegate.swift */,
0565133E1EF489CD009EA38F /* PhotoEditor+Gestures.swift */,
0565133F1EF489CD009EA38F /* PhotoEditor+Drawing.swift */,
056513401EF489CD009EA38F /* PhotoEditor+Keyboard.swift */,
056513411EF489CD009EA38F /* PhotoEditor+StickersViewController.swift */,
056513421EF489CD009EA38F /* PhotoEditor+UITextView.swift */,
Expand Down Expand Up @@ -190,19 +190,20 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Mohamed Hamed";
TargetAttributes = {
059EA7181EACB8790072C0FE = {
CreatedOnToolsVersion = 8.3;
DevelopmentTeam = B8BKM8368H;
DevelopmentTeam = C2PTZ27TNW;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 059EA7141EACB8780072C0FE /* Build configuration list for PBXProject "Photo Editor" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -292,21 +293,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -342,21 +352,30 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -385,27 +404,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = B8BKM8368H;
DEVELOPMENT_TEAM = C2PTZ27TNW;
INFOPLIST_FILE = "Photo Editor/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.hamed.Photo-Editor";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
059EA72D1EACB8790072C0FE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = B8BKM8368H;
DEVELOPMENT_TEAM = C2PTZ27TNW;
INFOPLIST_FILE = "Photo Editor/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.hamed.Photo-Editor";
PRODUCT_NAME = "$(TARGET_NAME)";
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
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Photo Editor/Photo Editor/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
10 changes: 5 additions & 5 deletions Photo Editor/Photo Editor/CropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
setupEditingRect()

if imageView == nil {
if UIInterfaceOrientationIsPortrait(interfaceOrientation) {
if interfaceOrientation.isPortrait {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginTop)
} else {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginLeft)
Expand All @@ -198,7 +198,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
setupZoomingView()
setupImageView()
} else if usingCustomImageView {
if UIInterfaceOrientationIsPortrait(interfaceOrientation) {
if interfaceOrientation.isPortrait {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginTop)
} else {
insetRect = bounds.insetBy(dx: MarginLeft, dy: MarginLeft)
Expand Down Expand Up @@ -257,7 +257,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
let cropRect = convert(scrollView.frame, to: zoomingView)
var ratio: CGFloat = 1.0
let orientation = UIApplication.shared.statusBarOrientation
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad || UIInterfaceOrientationIsPortrait(orientation)) {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad || orientation.isPortrait) {
ratio = AVMakeRect(aspectRatio: imageSize, insideRect: insetRect).width / imageSize.width
} else {
ratio = AVMakeRect(aspectRatio: imageSize, insideRect: insetRect).height / imageSize.height
Expand All @@ -276,7 +276,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,
return image.rotatedImageWithTransform(rotation, croppedToRect: zoomedCropRect())
}

func handleRotation(_ gestureRecognizer: UIRotationGestureRecognizer) {
@objc func handleRotation(_ gestureRecognizer: UIRotationGestureRecognizer) {
if let imageView = imageView {
let rotation = gestureRecognizer.rotation
let transform = imageView.transform.rotated(by: rotation)
Expand Down Expand Up @@ -304,7 +304,7 @@ open class CropView: UIView, UIScrollViewDelegate, UIGestureRecognizerDelegate,

fileprivate func setupEditingRect() {
let interfaceOrientation = UIApplication.shared.statusBarOrientation
if UIInterfaceOrientationIsPortrait(interfaceOrientation) {
if interfaceOrientation.isPortrait {
editingRect = bounds.insetBy(dx: MarginLeft, dy: MarginTop)
} else {
editingRect = bounds.insetBy(dx: MarginLeft, dy: MarginLeft)
Expand Down
12 changes: 6 additions & 6 deletions Photo Editor/Photo Editor/CropViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public protocol CropViewControllerDelegate: class {
func cropViewController(_ controller: CropViewController, didFinishCroppingImage image: UIImage, transform: CGAffineTransform, cropRect: CGRect)
func cropViewControllerDidCancel(_ controller: CropViewController)
}

@objc
open class CropViewController: UIViewController {
open weak var delegate: CropViewControllerDelegate?
open var image: UIImage? {
Expand Down Expand Up @@ -119,19 +119,19 @@ open class CropViewController: UIViewController {
cropView?.keepAspectRatio = keepAspectRatio
}

open func resetCropRect() {
@objc open func resetCropRect() {
cropView?.resetCropRect()
}

open func resetCropRectAnimated(_ animated: Bool) {
@objc open func resetCropRectAnimated(_ animated: Bool) {
cropView?.resetCropRectAnimated(animated)
}

func cancel(_ sender: UIBarButtonItem) {
@objc func cancel(_ sender: UIBarButtonItem) {
delegate?.cropViewControllerDidCancel(self)
}

func done(_ sender: UIBarButtonItem) {
@objc func done(_ sender: UIBarButtonItem) {
if let image = cropView?.croppedImage {
guard let rotation = cropView?.rotation else {
return
Expand All @@ -143,7 +143,7 @@ open class CropViewController: UIViewController {
}
}

func constrain(_ sender: UIBarButtonItem) {
@objc func constrain(_ sender: UIBarButtonItem) {
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let original = UIAlertAction(title: "Original", style: .default) { [unowned self] action in
guard let image = self.cropView?.image else {
Expand Down
8 changes: 4 additions & 4 deletions Photo Editor/Photo Editor/PhotoEditor+Controls.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extension PhotoEditorViewController {
width: UIScreen.main.bounds.width, height: 30))

textView.textAlignment = .center
textView.font = UIFont(name: "Helvetica", size: 30)
textView.font = self.textViewFontFamilly
textView.textColor = textColor
textView.layer.shadowColor = UIColor.black.cgColor
textView.layer.shadowOffset = CGSize(width: 1.0, height: 0.0)
Expand Down Expand Up @@ -108,9 +108,9 @@ extension PhotoEditorViewController {

//MAKR: helper methods

func image(_ image: UIImage, withPotentialError error: NSErrorPointer, contextInfo: UnsafeRawPointer) {
let alert = UIAlertController(title: "Image Saved", message: "Image successfully saved to Photos library", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
@objc func image(_ image: UIImage, withPotentialError error: NSErrorPointer, contextInfo: UnsafeRawPointer) {
let alert = UIAlertController(title: "Image Saved", message: "Image successfully saved to Photos library", preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}

Expand Down
5 changes: 4 additions & 1 deletion Photo Editor/Photo Editor/PhotoEditor+Drawing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,18 @@ extension PhotoEditorViewController {
context.addLine(to: CGPoint(x: toPoint.x, y: toPoint.y))
// 3
context.setLineCap( CGLineCap.round)
context.setLineWidth(5.0)
context.setLineWidth(drawWidth!)
context.setStrokeColor(drawColor.cgColor)
context.setBlendMode( CGBlendMode.normal)
// 4
context.strokePath()
// 5
canvasImageView.image = UIGraphicsGetImageFromCurrentImageContext()
canvasImageView.alpha = drawOpacity!

UIGraphicsEndImageContext()
}
}

}

2 changes: 1 addition & 1 deletion Photo Editor/Photo Editor/PhotoEditor+Font.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extension PhotoEditorViewController {
}
let font = CGFont(fontDataProvider)
var error: Unmanaged<CFError>?
guard CTFontManagerRegisterGraphicsFont(font, &error) else {
guard CTFontManagerRegisterGraphicsFont(font!, &error) else {
return
}
}
Expand Down
15 changes: 9 additions & 6 deletions Photo Editor/Photo Editor/PhotoEditor+Gestures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
UIPanGestureRecognizer - Moving Objects
Selecting transparent parts of the imageview won't move the object
*/
func panGesture(_ recognizer: UIPanGestureRecognizer) {
@objc func panGesture(_ recognizer: UIPanGestureRecognizer) {
if let view = recognizer.view {
if view is UIImageView {
//Tap only on visible parts on the image
Expand All @@ -43,7 +43,8 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
/**
UIPinchGestureRecognizer - Pinching Objects
If it's a UITextView will make the font bigger so it doen't look pixlated
*/
*/
@objc
func pinchGesture(_ recognizer: UIPinchGestureRecognizer) {
if let view = recognizer.view {
if view is UITextView {
Expand Down Expand Up @@ -74,7 +75,8 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {

/**
UIRotationGestureRecognizer - Rotating Objects
*/
*/
@objc
func rotationGesture(_ recognizer: UIRotationGestureRecognizer) {
if let view = recognizer.view {
view.transform = view.transform.rotated(by: recognizer.rotation)
Expand All @@ -87,6 +89,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
Will make scale scale Effect
Selecting transparent parts of the imageview won't move the object
*/
@objc
func tapGesture(_ recognizer: UITapGestureRecognizer) {
if let view = recognizer.view {
if view is UIImageView {
Expand Down Expand Up @@ -120,7 +123,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
return false
}

func screenEdgeSwiped(_ recognizer: UIScreenEdgePanGestureRecognizer) {
@objc func screenEdgeSwiped(_ recognizer: UIScreenEdgePanGestureRecognizer) {
if recognizer.state == .recognized {
if !stickersVCIsVisible {
addStickersViewController()
Expand All @@ -137,7 +140,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
Scale Effect
*/
func scaleEffect(view: UIView) {
view.superview?.bringSubview(toFront: view)
view.superview?.bringSubviewToFront(view)

if #available(iOS 10.0, *) {
let generator = UIImpactFeedbackGenerator(style: .heavy)
Expand Down Expand Up @@ -166,7 +169,7 @@ extension PhotoEditorViewController : UIGestureRecognizerDelegate {
hideToolbar(hide: true)
deleteView.isHidden = false

view.superview?.bringSubview(toFront: view)
view.superview?.bringSubviewToFront(view)
let pointToSuperView = recognizer.location(in: self.view)

view.center = CGPoint(x: view.center.x + recognizer.translation(in: canvasImageView).x,
Expand Down
Loading