├── .gitignore ├── Animated Play Button Example.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── Animated Play Button Example ├── AnimatedStartButton.swift ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── play_button.imageset │ │ ├── Contents.json │ │ └── play_button.pdf ├── Info.plist └── ViewController.swift ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | .DS_Store 21 | 22 | # CocoaPods 23 | # 24 | # We recommend against adding the Pods directory to your .gitignore. However 25 | # you should judge for yourself, the pros and cons are mentioned at: 26 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 27 | # 28 | # Pods/ 29 | -------------------------------------------------------------------------------- /Animated Play Button Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 92482EEA1A66A8570027D79B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92482EE91A66A8570027D79B /* AppDelegate.swift */; }; 11 | 92482EEC1A66A8570027D79B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92482EEB1A66A8570027D79B /* ViewController.swift */; }; 12 | 92482EEF1A66A8570027D79B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 92482EED1A66A8570027D79B /* Main.storyboard */; }; 13 | 92482EF11A66A8570027D79B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92482EF01A66A8570027D79B /* Images.xcassets */; }; 14 | 92482F0C1A66A9F40027D79B /* AnimatedStartButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92482F0B1A66A9F40027D79B /* AnimatedStartButton.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 92482EE41A66A8570027D79B /* Animated Play Button Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Animated Play Button Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 92482EE81A66A8570027D79B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 20 | 92482EE91A66A8570027D79B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 92482EEB1A66A8570027D79B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 92482EEE1A66A8570027D79B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 92482EF01A66A8570027D79B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 24 | 92482F0B1A66A9F40027D79B /* AnimatedStartButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedStartButton.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 92482EE11A66A8570027D79B /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 92482EDB1A66A8570027D79B = { 39 | isa = PBXGroup; 40 | children = ( 41 | 92482EE61A66A8570027D79B /* Animated Play Button Example */, 42 | 92482EE51A66A8570027D79B /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 92482EE51A66A8570027D79B /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 92482EE41A66A8570027D79B /* Animated Play Button Example.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 92482EE61A66A8570027D79B /* Animated Play Button Example */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 92482EE91A66A8570027D79B /* AppDelegate.swift */, 58 | 92482EEB1A66A8570027D79B /* ViewController.swift */, 59 | 92482F0B1A66A9F40027D79B /* AnimatedStartButton.swift */, 60 | 92482EED1A66A8570027D79B /* Main.storyboard */, 61 | 92482EF01A66A8570027D79B /* Images.xcassets */, 62 | 92482EE71A66A8570027D79B /* Supporting Files */, 63 | ); 64 | path = "Animated Play Button Example"; 65 | sourceTree = ""; 66 | }; 67 | 92482EE71A66A8570027D79B /* Supporting Files */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 92482EE81A66A8570027D79B /* Info.plist */, 71 | ); 72 | name = "Supporting Files"; 73 | sourceTree = ""; 74 | }; 75 | /* End PBXGroup section */ 76 | 77 | /* Begin PBXNativeTarget section */ 78 | 92482EE31A66A8570027D79B /* Animated Play Button Example */ = { 79 | isa = PBXNativeTarget; 80 | buildConfigurationList = 92482F031A66A8570027D79B /* Build configuration list for PBXNativeTarget "Animated Play Button Example" */; 81 | buildPhases = ( 82 | 92482EE01A66A8570027D79B /* Sources */, 83 | 92482EE11A66A8570027D79B /* Frameworks */, 84 | 92482EE21A66A8570027D79B /* Resources */, 85 | ); 86 | buildRules = ( 87 | ); 88 | dependencies = ( 89 | ); 90 | name = "Animated Play Button Example"; 91 | productName = "Animated Play Button Example"; 92 | productReference = 92482EE41A66A8570027D79B /* Animated Play Button Example.app */; 93 | productType = "com.apple.product-type.application"; 94 | }; 95 | /* End PBXNativeTarget section */ 96 | 97 | /* Begin PBXProject section */ 98 | 92482EDC1A66A8570027D79B /* Project object */ = { 99 | isa = PBXProject; 100 | attributes = { 101 | LastUpgradeCheck = 0610; 102 | ORGANIZATIONNAME = "Alpine Pipeline"; 103 | TargetAttributes = { 104 | 92482EE31A66A8570027D79B = { 105 | CreatedOnToolsVersion = 6.1.1; 106 | }; 107 | }; 108 | }; 109 | buildConfigurationList = 92482EDF1A66A8570027D79B /* Build configuration list for PBXProject "Animated Play Button Example" */; 110 | compatibilityVersion = "Xcode 3.2"; 111 | developmentRegion = English; 112 | hasScannedForEncodings = 0; 113 | knownRegions = ( 114 | en, 115 | Base, 116 | ); 117 | mainGroup = 92482EDB1A66A8570027D79B; 118 | productRefGroup = 92482EE51A66A8570027D79B /* Products */; 119 | projectDirPath = ""; 120 | projectRoot = ""; 121 | targets = ( 122 | 92482EE31A66A8570027D79B /* Animated Play Button Example */, 123 | ); 124 | }; 125 | /* End PBXProject section */ 126 | 127 | /* Begin PBXResourcesBuildPhase section */ 128 | 92482EE21A66A8570027D79B /* Resources */ = { 129 | isa = PBXResourcesBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | 92482EEF1A66A8570027D79B /* Main.storyboard in Resources */, 133 | 92482EF11A66A8570027D79B /* Images.xcassets in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | 92482EE01A66A8570027D79B /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 92482F0C1A66A9F40027D79B /* AnimatedStartButton.swift in Sources */, 145 | 92482EEC1A66A8570027D79B /* ViewController.swift in Sources */, 146 | 92482EEA1A66A8570027D79B /* AppDelegate.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin PBXVariantGroup section */ 153 | 92482EED1A66A8570027D79B /* Main.storyboard */ = { 154 | isa = PBXVariantGroup; 155 | children = ( 156 | 92482EEE1A66A8570027D79B /* Base */, 157 | ); 158 | name = Main.storyboard; 159 | sourceTree = ""; 160 | }; 161 | /* End PBXVariantGroup section */ 162 | 163 | /* Begin XCBuildConfiguration section */ 164 | 92482F011A66A8570027D79B /* Debug */ = { 165 | isa = XCBuildConfiguration; 166 | buildSettings = { 167 | ALWAYS_SEARCH_USER_PATHS = NO; 168 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 169 | CLANG_CXX_LIBRARY = "libc++"; 170 | CLANG_ENABLE_MODULES = YES; 171 | CLANG_ENABLE_OBJC_ARC = YES; 172 | CLANG_WARN_BOOL_CONVERSION = YES; 173 | CLANG_WARN_CONSTANT_CONVERSION = YES; 174 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 175 | CLANG_WARN_EMPTY_BODY = YES; 176 | CLANG_WARN_ENUM_CONVERSION = YES; 177 | CLANG_WARN_INT_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_UNREACHABLE_CODE = YES; 180 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 181 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 182 | COPY_PHASE_STRIP = NO; 183 | ENABLE_STRICT_OBJC_MSGSEND = YES; 184 | GCC_C_LANGUAGE_STANDARD = gnu99; 185 | GCC_DYNAMIC_NO_PIC = NO; 186 | GCC_OPTIMIZATION_LEVEL = 0; 187 | GCC_PREPROCESSOR_DEFINITIONS = ( 188 | "DEBUG=1", 189 | "$(inherited)", 190 | ); 191 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 192 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 193 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 194 | GCC_WARN_UNDECLARED_SELECTOR = YES; 195 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 196 | GCC_WARN_UNUSED_FUNCTION = YES; 197 | GCC_WARN_UNUSED_VARIABLE = YES; 198 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 199 | MTL_ENABLE_DEBUG_INFO = YES; 200 | ONLY_ACTIVE_ARCH = YES; 201 | SDKROOT = iphoneos; 202 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 203 | TARGETED_DEVICE_FAMILY = "1,2"; 204 | }; 205 | name = Debug; 206 | }; 207 | 92482F021A66A8570027D79B /* Release */ = { 208 | isa = XCBuildConfiguration; 209 | buildSettings = { 210 | ALWAYS_SEARCH_USER_PATHS = NO; 211 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 212 | CLANG_CXX_LIBRARY = "libc++"; 213 | CLANG_ENABLE_MODULES = YES; 214 | CLANG_ENABLE_OBJC_ARC = YES; 215 | CLANG_WARN_BOOL_CONVERSION = YES; 216 | CLANG_WARN_CONSTANT_CONVERSION = YES; 217 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 218 | CLANG_WARN_EMPTY_BODY = YES; 219 | CLANG_WARN_ENUM_CONVERSION = YES; 220 | CLANG_WARN_INT_CONVERSION = YES; 221 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 222 | CLANG_WARN_UNREACHABLE_CODE = YES; 223 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 224 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 225 | COPY_PHASE_STRIP = YES; 226 | ENABLE_NS_ASSERTIONS = NO; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | GCC_C_LANGUAGE_STANDARD = gnu99; 229 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 230 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 231 | GCC_WARN_UNDECLARED_SELECTOR = YES; 232 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 233 | GCC_WARN_UNUSED_FUNCTION = YES; 234 | GCC_WARN_UNUSED_VARIABLE = YES; 235 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 236 | MTL_ENABLE_DEBUG_INFO = NO; 237 | SDKROOT = iphoneos; 238 | TARGETED_DEVICE_FAMILY = "1,2"; 239 | VALIDATE_PRODUCT = YES; 240 | }; 241 | name = Release; 242 | }; 243 | 92482F041A66A8570027D79B /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 247 | INFOPLIST_FILE = "Animated Play Button Example/Info.plist"; 248 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 249 | PRODUCT_NAME = "$(TARGET_NAME)"; 250 | }; 251 | name = Debug; 252 | }; 253 | 92482F051A66A8570027D79B /* Release */ = { 254 | isa = XCBuildConfiguration; 255 | buildSettings = { 256 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 257 | INFOPLIST_FILE = "Animated Play Button Example/Info.plist"; 258 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 259 | PRODUCT_NAME = "$(TARGET_NAME)"; 260 | }; 261 | name = Release; 262 | }; 263 | /* End XCBuildConfiguration section */ 264 | 265 | /* Begin XCConfigurationList section */ 266 | 92482EDF1A66A8570027D79B /* Build configuration list for PBXProject "Animated Play Button Example" */ = { 267 | isa = XCConfigurationList; 268 | buildConfigurations = ( 269 | 92482F011A66A8570027D79B /* Debug */, 270 | 92482F021A66A8570027D79B /* Release */, 271 | ); 272 | defaultConfigurationIsVisible = 0; 273 | defaultConfigurationName = Release; 274 | }; 275 | 92482F031A66A8570027D79B /* Build configuration list for PBXNativeTarget "Animated Play Button Example" */ = { 276 | isa = XCConfigurationList; 277 | buildConfigurations = ( 278 | 92482F041A66A8570027D79B /* Debug */, 279 | 92482F051A66A8570027D79B /* Release */, 280 | ); 281 | defaultConfigurationIsVisible = 0; 282 | defaultConfigurationName = Release; 283 | }; 284 | /* End XCConfigurationList section */ 285 | }; 286 | rootObject = 92482EDC1A66A8570027D79B /* Project object */; 287 | } 288 | -------------------------------------------------------------------------------- /Animated Play Button Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Animated Play Button Example/AnimatedStartButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatedStartButton.swift 3 | // walktracker 4 | // 5 | // Created by Kevin VanderLugt on 1/13/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import CoreGraphics 10 | import QuartzCore 11 | import UIKit 12 | 13 | class AnimatedStartButton : UIButton { 14 | 15 | // The horizontal disantce between the two lines in pause mode 16 | let pauseSpace: CGFloat = 10.0 17 | 18 | // This is due to the graphic being larger from the drop shadows 19 | let shadowPadding: CGFloat = 8.0 20 | 21 | let linePath: CGPath = { 22 | let path = CGPathCreateMutable() 23 | CGPathMoveToPoint(path, nil, 0, 0) 24 | CGPathAddLineToPoint(path, nil, 0, 12) 25 | 26 | return path 27 | }() 28 | 29 | let bottomTransform = CATransform3DRotate(CATransform3DMakeTranslation(0, 2, 0), CGFloat(M_PI/4), 0, 0, 1) 30 | let topTransform = CATransform3DRotate(CATransform3DMakeTranslation(-10, -2, 0), CGFloat(-M_PI/4), 0, 0, 1) 31 | 32 | override var selected: Bool { 33 | didSet { 34 | addTransforms() 35 | } 36 | } 37 | 38 | var top: CAShapeLayer! = CAShapeLayer() 39 | var bottom: CAShapeLayer! = CAShapeLayer() 40 | 41 | required init(coder aDecoder: NSCoder) { 42 | super.init(coder: aDecoder) 43 | self.setupPaths() 44 | } 45 | 46 | override init(frame: CGRect) { 47 | super.init(frame: frame) 48 | self.setupPaths() 49 | } 50 | 51 | func setupPaths() { 52 | let lineWidth: CGFloat = 2 53 | 54 | self.top.path = linePath 55 | self.bottom.path = linePath 56 | 57 | for layer in [ self.top, self.bottom ] { 58 | layer.fillColor = nil 59 | layer.strokeColor = UIColor.whiteColor().CGColor 60 | layer.lineWidth = lineWidth 61 | layer.lineCap = kCALineCapSquare 62 | layer.masksToBounds = true 63 | 64 | let strokingPath = CGPathCreateCopyByStrokingPath(layer.path, nil, lineWidth*2, kCGLineCapSquare, kCGLineJoinMiter, 0) 65 | layer.bounds = CGPathGetPathBoundingBox(strokingPath) 66 | layer.actions = [ 67 | "strokeStart": NSNull(), 68 | "strokeEnd": NSNull(), 69 | "transform": NSNull() 70 | ] 71 | 72 | self.layer.addSublayer(layer) 73 | } 74 | 75 | self.top.anchorPoint = CGPointMake(0.5, 0.0) 76 | self.top.position = CGPointMake(self.frame.size.width/2 + pauseSpace/2, (self.frame.size.height-shadowPadding)/2 - 12/2 ) 77 | self.top.transform = topTransform 78 | 79 | self.bottom.anchorPoint = CGPointMake(0.5, 1.0) 80 | self.bottom.position = CGPointMake(self.frame.size.width/2 - pauseSpace/2, self.top.position.y + 12 + shadowPadding/2) 81 | self.bottom.transform = bottomTransform 82 | } 83 | 84 | 85 | func addTransforms() { 86 | let bottomAnimation = CABasicAnimation(keyPath: "transform") 87 | bottomAnimation.duration = 0.4 88 | bottomAnimation.fillMode = kCAFillModeBackwards 89 | bottomAnimation.timingFunction = CAMediaTimingFunction(controlPoints: 0.5, -0.8, 0.5, 1.85) 90 | 91 | let topAnimation = bottomAnimation.copy() as CABasicAnimation 92 | 93 | if (selected) { 94 | bottomAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity) 95 | topAnimation.toValue = NSValue(CATransform3D: CATransform3DIdentity) 96 | } 97 | else { 98 | bottomAnimation.toValue = NSValue(CATransform3D: bottomTransform) 99 | topAnimation.toValue = NSValue(CATransform3D: topTransform) 100 | } 101 | self.bottom.kv_applyAnimation(bottomAnimation) 102 | self.top.kv_applyAnimation(topAnimation) 103 | } 104 | 105 | } 106 | 107 | extension CALayer { 108 | func kv_applyAnimation(animation: CABasicAnimation) { 109 | let copy = animation.copy() as CABasicAnimation 110 | 111 | if copy.fromValue == nil { 112 | copy.fromValue = self.presentationLayer().valueForKeyPath(copy.keyPath) 113 | } 114 | 115 | self.addAnimation(copy, forKey: copy.keyPath) 116 | self.setValue(copy.toValue, forKeyPath:copy.keyPath) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Animated Play Button Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Animated Play Button Example 4 | // 5 | // Created by Kevin VanderLugt on 1/14/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Animated Play Button Example/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Animated Play Button Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Animated Play Button Example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Animated Play Button Example/Images.xcassets/play_button.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "play_button.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /Animated Play Button Example/Images.xcassets/play_button.imageset/play_button.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinvanderlugt/Swift-Animated-Play-Button/9f347211c8463d0b51a1585157579020ed22953d/Animated Play Button Example/Images.xcassets/play_button.imageset/play_button.pdf -------------------------------------------------------------------------------- /Animated Play Button Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.alpinepipeline.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Animated Play Button Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Animated Play Button Example 4 | // 5 | // Created by Kevin VanderLugt on 1/14/15. 6 | // Copyright (c) 2015 Alpine Pipeline. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | @IBAction func buttonPressed(sender: UIButton) { 24 | sender.selected = !sender.selected 25 | } 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kevin VanderLugt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swift Animated Play Button 2 | An animated Play/Pause button using Google's material design ideas in Swift 3 | 4 |

5 | 6 |

7 | 8 | I am playing around with animating a play button for my open source walk tracking app in Swift. 9 | Currently a work in progress and I plan to write about it a bit more 10 | 11 | 12 | ##### Todos 13 | * It would be nice to have the positioning of the lines work depending on the frame size 14 | * Programatiacally be able to add drop shadows so that we don't need to adjust the offset 15 | * Let users choose their line width and color 16 | --------------------------------------------------------------------------------