From 2124662377ea610253593af931153c4fe02a4832 Mon Sep 17 00:00:00 2001 From: Seema Kamath Date: Wed, 28 Sep 2016 13:23:43 -0700 Subject: [PATCH 1/2] Convert the framework to Swift 3 --- DOFavoriteButton-DEMO/.DS_Store | Bin 0 -> 6148 bytes .../project.pbxproj | 15 +- .../xcschemes/DOFavoriteButton.xcscheme | 2 +- .../AppIcon.appiconset/Contents.json | 25 +++ DOFavoriteButton/DOFavoriteButton.swift | 202 +++++++++--------- 5 files changed, 142 insertions(+), 102 deletions(-) create mode 100644 DOFavoriteButton-DEMO/.DS_Store diff --git a/DOFavoriteButton-DEMO/.DS_Store b/DOFavoriteButton-DEMO/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0a9f367d4c2fdd67c5878dd921237adda8834f7f GIT binary patch literal 6148 zcmeHLO-jU24F29YixD^D&Yiu0!rY*gjyrKN7f`0+57riG#bwXo(i6E5y@RLl%S$LT zR97RSl0fpcuSweX1)8P+Le>^DUTUv0+7TaX^nbj_GxX2Q0Z(u);NKUE%uXVzyXTWv$zLeBV4{ zS><`rHcQ}T_iZoc-S8R9s^~MmK7B{V`f_#G&$@ZH&VV!E4EzlS*t10@JBn_d0cXG& z=oygrLqZiy4Lim7>Y#}u08u_8qwrW}35iJzQ^QV?S13V4i5ePg#0VPB^~C&A!%k7d z5p4JfcIRLdN{Dx7{v^61q>65x0cT*Hfh|3qO8=jKJ^!x<`I$4|4E!qw!Z=^#8MkD; wb+9? Date: Wed, 28 Sep 2016 13:36:16 -0700 Subject: [PATCH 2/2] update demo app to Swift 3 --- DOFavoriteButton-DEMO/.DS_Store | Bin 6148 -> 6148 bytes .../project.pbxproj | 39 ++++++++++++++++++ .../DOFavoriteButton-DEMO/AppDelegate.swift | 12 +++--- .../Base.lproj/LaunchScreen.xib | 12 ++---- .../Base.lproj/Main.storyboard | 24 +++++------ .../ViewController.swift | 22 +++++----- 6 files changed, 70 insertions(+), 39 deletions(-) diff --git a/DOFavoriteButton-DEMO/.DS_Store b/DOFavoriteButton-DEMO/.DS_Store index 0a9f367d4c2fdd67c5878dd921237adda8834f7f..e7b6c7ca46141b3b93e5459f05d1cd69fa228a7e 100644 GIT binary patch delta 63 zcmZoMXffCj!^E_6?c@ziE<7$SDWxUJ3=CHUZ*HB$?829up8^-TE-{HYi1EYbMCN5I N6C3z8vvd6A2LRT(7L))0 delta 53 zcmV-50LuS_FoZC$Tmk}`>XWbnL;*yT^#V^0ZEs{mWOa07007hx)}oRFQUTDjVFRWF Lk$?`f2MGNS7$Os? diff --git a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/project.pbxproj b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/project.pbxproj index f4b3f97..3db2618 100644 --- a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/project.pbxproj +++ b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/project.pbxproj @@ -14,6 +14,8 @@ 4FBAA7081B4D807F00C8657F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA7061B4D807F00C8657F /* Main.storyboard */; }; 4FBAA70A1B4D807F00C8657F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA7091B4D807F00C8657F /* Images.xcassets */; }; 4FBAA70D1B4D807F00C8657F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA70B1B4D807F00C8657F /* LaunchScreen.xib */; }; + 8465A9631D9C60B500B1D8C4 /* DOFavoriteButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */; }; + 8465A9641D9C60B500B1D8C4 /* DOFavoriteButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXBuildRule section */ @@ -28,6 +30,30 @@ }; /* End PBXBuildRule section */ +/* Begin PBXContainerItemProxy section */ + 8465A9651D9C60B500B1D8C4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4FBAA6F51B4D807F00C8657F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4F60711A1B6366ED0058F570; + remoteInfo = DOFavoriteButton; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 8465A9671D9C60B500B1D8C4 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 8465A9641D9C60B500B1D8C4 /* DOFavoriteButton.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DOFavoriteButton.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4F60711E1B6366ED0058F570 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -54,6 +80,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 8465A9631D9C60B500B1D8C4 /* DOFavoriteButton.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -157,10 +184,12 @@ 4FBAA6F91B4D807F00C8657F /* Sources */, 4FBAA6FA1B4D807F00C8657F /* Frameworks */, 4FBAA6FB1B4D807F00C8657F /* Resources */, + 8465A9671D9C60B500B1D8C4 /* Embed Frameworks */, ); buildRules = ( ); dependencies = ( + 8465A9661D9C60B500B1D8C4 /* PBXTargetDependency */, ); name = "DOFavoriteButton-DEMO"; productName = "DOFavoriteButton-DEMO"; @@ -247,6 +276,14 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + 8465A9661D9C60B500B1D8C4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4F60711A1B6366ED0058F570 /* DOFavoriteButton */; + targetProxy = 8465A9651D9C60B500B1D8C4 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin PBXVariantGroup section */ 4FBAA7061B4D807F00C8657F /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -410,6 +447,7 @@ 4FBAA71D1B4D807F00C8657F /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = "DOFavoriteButton-DEMO/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -423,6 +461,7 @@ 4FBAA71E1B4D807F00C8657F /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = "DOFavoriteButton-DEMO/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; diff --git a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/AppDelegate.swift b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/AppDelegate.swift index d3cf69d..5ce43bf 100644 --- a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/AppDelegate.swift +++ b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/AppDelegate.swift @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/LaunchScreen.xib b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/LaunchScreen.xib index cbcb182..bb58b81 100644 --- a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/LaunchScreen.xib +++ b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/LaunchScreen.xib @@ -1,9 +1,10 @@ - + - + + @@ -13,22 +14,17 @@ - - + diff --git a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/Main.storyboard b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/Main.storyboard index 280b163..a5f05b1 100644 --- a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/Main.storyboard +++ b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + - + + @@ -14,42 +15,37 @@ - + - - + diff --git a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift index 99be5ed..910f2ee 100644 --- a/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift +++ b/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift @@ -21,38 +21,38 @@ class ViewController: UIViewController { let y = self.view.frame.height / 2 - 22 // star button - let starButton = DOFavoriteButton(frame: CGRectMake(x, y, 44, 44), image: UIImage(named: "star")) - starButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + let starButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "star")) + starButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), for: UIControlEvents.touchUpInside) self.view.addSubview(starButton) x += width // heart button - let heartButton = DOFavoriteButton(frame: CGRectMake(x, y, 44, 44), image: UIImage(named: "heart")) + let heartButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "heart")) heartButton.imageColorOn = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0) heartButton.circleColor = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0) heartButton.lineColor = UIColor(red: 226/255, green: 96/255, blue: 96/255, alpha: 1.0) - heartButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + heartButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), for: UIControlEvents.touchUpInside) self.view.addSubview(heartButton) x += width // like button - let likeButton = DOFavoriteButton(frame: CGRectMake(x, y, 44, 44), image: UIImage(named: "like")) + let likeButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "like")) likeButton.imageColorOn = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0) likeButton.circleColor = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0) likeButton.lineColor = UIColor(red: 41/255, green: 128/255, blue: 185/255, alpha: 1.0) - likeButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + likeButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), for: UIControlEvents.touchUpInside) self.view.addSubview(likeButton) x += width // smile button - let smileButton = DOFavoriteButton(frame: CGRectMake(x, y, 44, 44), image: UIImage(named: "smile")) + let smileButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "smile")) smileButton.imageColorOn = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0) smileButton.circleColor = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0) smileButton.lineColor = UIColor(red: 45/255, green: 195/255, blue: 106/255, alpha: 1.0) - smileButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + smileButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), for: UIControlEvents.touchUpInside) self.view.addSubview(smileButton) - self.heartButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside) + self.heartButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), for: UIControlEvents.touchUpInside) } override func didReceiveMemoryWarning() { @@ -60,8 +60,8 @@ class ViewController: UIViewController { // Dispose of any resources that can be recreated. } - func tappedButton(sender: DOFavoriteButton) { - if sender.selected { + func tappedButton(_ sender: DOFavoriteButton) { + if sender.isSelected { sender.deselect() } else { sender.select()