├── .gitignore ├── .swift-version ├── CHANGELOG.md ├── LICENSE ├── PlaybackButton.podspec ├── PlaybackButton.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── a12447.xcuserdatad │ └── xcschemes │ ├── PlaybackButton.xcscheme │ └── xcschememanagement.plist ├── PlaybackButton ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Extensions │ ├── String.swift │ └── UIColor.swift ├── Info.plist └── ViewController.swift ├── PlaybackButtonTests ├── Info.plist └── PlaybackButtonTests.swift ├── PlaybackButtonUITests ├── Info.plist └── PlaybackButtonUITests.swift ├── README.md ├── Screenshots └── PlaybackButton.gif └── Source └── PlaybackButton.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | *.xcscmblueprint 24 | 25 | # CocoaPods 26 | # 27 | # We recommend against adding the Pods directory to your .gitignore. However 28 | # you should judge for yourself, the pros and cons are mentioned at: 29 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 30 | # 31 | # Pods/ 32 | 33 | # Carthage 34 | # 35 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 36 | # Carthage/Checkouts 37 | 38 | Carthage/Build 39 | fastlane/report.xml 40 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0.2.0 Release notes (2016-03-04) 4 | ============================================================= 5 | 6 | ### Enhancements 7 | * Add IF of animation duration setting. 8 | * Add IF of button color setting. 9 | * Improve sample project. 10 | 11 | ### Bugfixes 12 | 13 | * None. 14 | 15 | 16 | 0.1.0 Release notes (2016-01-01) 17 | ============================================================= 18 | 19 | ### Enhancements 20 | 21 | * Initial release. 22 | 23 | ### Bugfixes 24 | 25 | * None. 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yuji Hato 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /PlaybackButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "PlaybackButton" 3 | s.version = "0.4.0" 4 | s.summary = "iOS animation playback button inspired by the playback button of YouTube for web." 5 | s.homepage = "https://github.com/dekatotoro/PlaybackButton" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = { "Yuji Hato" => "hatoyujidev@gmail.com" } 8 | s.social_media_url = "https://twitter.com/dekatotoro" 9 | s.platform = :ios 10 | s.ios.deployment_target = "8.0" 11 | s.source = { :git => "https://github.com/dekatotoro/PlaybackButton.git", :tag => s.version } 12 | s.source_files = "Source/*" 13 | s.requires_arc = true 14 | end 15 | -------------------------------------------------------------------------------- /PlaybackButton.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C5D0432D1C367E580088850C /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D0432B1C367E580088850C /* String.swift */; }; 11 | C5D0432E1C367E580088850C /* UIColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D0432C1C367E580088850C /* UIColor.swift */; }; 12 | C5ED1EBE1C1E880900F8F27F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5ED1EBD1C1E880900F8F27F /* AppDelegate.swift */; }; 13 | C5ED1EC01C1E880900F8F27F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5ED1EBF1C1E880900F8F27F /* ViewController.swift */; }; 14 | C5ED1EC31C1E880900F8F27F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C5ED1EC11C1E880900F8F27F /* Main.storyboard */; }; 15 | C5ED1EC51C1E880900F8F27F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C5ED1EC41C1E880900F8F27F /* Assets.xcassets */; }; 16 | C5ED1EC81C1E880900F8F27F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C5ED1EC61C1E880900F8F27F /* LaunchScreen.storyboard */; }; 17 | C5ED1ED31C1E880900F8F27F /* PlaybackButtonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5ED1ED21C1E880900F8F27F /* PlaybackButtonTests.swift */; }; 18 | C5ED1EDE1C1E880900F8F27F /* PlaybackButtonUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5ED1EDD1C1E880900F8F27F /* PlaybackButtonUITests.swift */; }; 19 | C5ED1EF01C1E890500F8F27F /* PlaybackButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5ED1EEF1C1E890500F8F27F /* PlaybackButton.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | C5ED1ECF1C1E880900F8F27F /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = C5ED1EB21C1E880900F8F27F /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = C5ED1EB91C1E880900F8F27F; 28 | remoteInfo = PlaybackButton; 29 | }; 30 | C5ED1EDA1C1E880900F8F27F /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = C5ED1EB21C1E880900F8F27F /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = C5ED1EB91C1E880900F8F27F; 35 | remoteInfo = PlaybackButton; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | C5D0432B1C367E580088850C /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = String.swift; path = Extensions/String.swift; sourceTree = ""; }; 41 | C5D0432C1C367E580088850C /* UIColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIColor.swift; path = Extensions/UIColor.swift; sourceTree = ""; }; 42 | C5ED1EBA1C1E880900F8F27F /* PlaybackButton.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PlaybackButton.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | C5ED1EBD1C1E880900F8F27F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 44 | C5ED1EBF1C1E880900F8F27F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 45 | C5ED1EC21C1E880900F8F27F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | C5ED1EC41C1E880900F8F27F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | C5ED1EC71C1E880900F8F27F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | C5ED1EC91C1E880900F8F27F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | C5ED1ECE1C1E880900F8F27F /* PlaybackButtonTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlaybackButtonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | C5ED1ED21C1E880900F8F27F /* PlaybackButtonTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackButtonTests.swift; sourceTree = ""; }; 51 | C5ED1ED41C1E880900F8F27F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | C5ED1ED91C1E880900F8F27F /* PlaybackButtonUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlaybackButtonUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | C5ED1EDD1C1E880900F8F27F /* PlaybackButtonUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackButtonUITests.swift; sourceTree = ""; }; 54 | C5ED1EDF1C1E880900F8F27F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | C5ED1EEF1C1E890500F8F27F /* PlaybackButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlaybackButton.swift; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | C5ED1EB71C1E880900F8F27F /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | C5ED1ECB1C1E880900F8F27F /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | C5ED1ED61C1E880900F8F27F /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | C5D0432A1C367E480088850C /* Extensions */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | C5D0432B1C367E580088850C /* String.swift */, 87 | C5D0432C1C367E580088850C /* UIColor.swift */, 88 | ); 89 | name = Extensions; 90 | sourceTree = ""; 91 | }; 92 | C5ED1EB11C1E880900F8F27F = { 93 | isa = PBXGroup; 94 | children = ( 95 | C5ED1EEE1C1E88F700F8F27F /* Source */, 96 | C5ED1EBC1C1E880900F8F27F /* PlaybackButton */, 97 | C5ED1ED11C1E880900F8F27F /* PlaybackButtonTests */, 98 | C5ED1EDC1C1E880900F8F27F /* PlaybackButtonUITests */, 99 | C5ED1EBB1C1E880900F8F27F /* Products */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | C5ED1EBB1C1E880900F8F27F /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | C5ED1EBA1C1E880900F8F27F /* PlaybackButton.app */, 107 | C5ED1ECE1C1E880900F8F27F /* PlaybackButtonTests.xctest */, 108 | C5ED1ED91C1E880900F8F27F /* PlaybackButtonUITests.xctest */, 109 | ); 110 | name = Products; 111 | sourceTree = ""; 112 | }; 113 | C5ED1EBC1C1E880900F8F27F /* PlaybackButton */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | C5D0432A1C367E480088850C /* Extensions */, 117 | C5ED1EBD1C1E880900F8F27F /* AppDelegate.swift */, 118 | C5ED1EBF1C1E880900F8F27F /* ViewController.swift */, 119 | C5ED1EC11C1E880900F8F27F /* Main.storyboard */, 120 | C5ED1EC41C1E880900F8F27F /* Assets.xcassets */, 121 | C5ED1EC61C1E880900F8F27F /* LaunchScreen.storyboard */, 122 | C5ED1EC91C1E880900F8F27F /* Info.plist */, 123 | ); 124 | path = PlaybackButton; 125 | sourceTree = ""; 126 | }; 127 | C5ED1ED11C1E880900F8F27F /* PlaybackButtonTests */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | C5ED1ED21C1E880900F8F27F /* PlaybackButtonTests.swift */, 131 | C5ED1ED41C1E880900F8F27F /* Info.plist */, 132 | ); 133 | path = PlaybackButtonTests; 134 | sourceTree = ""; 135 | }; 136 | C5ED1EDC1C1E880900F8F27F /* PlaybackButtonUITests */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | C5ED1EDD1C1E880900F8F27F /* PlaybackButtonUITests.swift */, 140 | C5ED1EDF1C1E880900F8F27F /* Info.plist */, 141 | ); 142 | path = PlaybackButtonUITests; 143 | sourceTree = ""; 144 | }; 145 | C5ED1EEE1C1E88F700F8F27F /* Source */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | C5ED1EEF1C1E890500F8F27F /* PlaybackButton.swift */, 149 | ); 150 | path = Source; 151 | sourceTree = ""; 152 | }; 153 | /* End PBXGroup section */ 154 | 155 | /* Begin PBXNativeTarget section */ 156 | C5ED1EB91C1E880900F8F27F /* PlaybackButton */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = C5ED1EE21C1E880900F8F27F /* Build configuration list for PBXNativeTarget "PlaybackButton" */; 159 | buildPhases = ( 160 | C5ED1EB61C1E880900F8F27F /* Sources */, 161 | C5ED1EB71C1E880900F8F27F /* Frameworks */, 162 | C5ED1EB81C1E880900F8F27F /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = PlaybackButton; 169 | productName = PlaybackButton; 170 | productReference = C5ED1EBA1C1E880900F8F27F /* PlaybackButton.app */; 171 | productType = "com.apple.product-type.application"; 172 | }; 173 | C5ED1ECD1C1E880900F8F27F /* PlaybackButtonTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = C5ED1EE51C1E880900F8F27F /* Build configuration list for PBXNativeTarget "PlaybackButtonTests" */; 176 | buildPhases = ( 177 | C5ED1ECA1C1E880900F8F27F /* Sources */, 178 | C5ED1ECB1C1E880900F8F27F /* Frameworks */, 179 | C5ED1ECC1C1E880900F8F27F /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | C5ED1ED01C1E880900F8F27F /* PBXTargetDependency */, 185 | ); 186 | name = PlaybackButtonTests; 187 | productName = PlaybackButtonTests; 188 | productReference = C5ED1ECE1C1E880900F8F27F /* PlaybackButtonTests.xctest */; 189 | productType = "com.apple.product-type.bundle.unit-test"; 190 | }; 191 | C5ED1ED81C1E880900F8F27F /* PlaybackButtonUITests */ = { 192 | isa = PBXNativeTarget; 193 | buildConfigurationList = C5ED1EE81C1E880900F8F27F /* Build configuration list for PBXNativeTarget "PlaybackButtonUITests" */; 194 | buildPhases = ( 195 | C5ED1ED51C1E880900F8F27F /* Sources */, 196 | C5ED1ED61C1E880900F8F27F /* Frameworks */, 197 | C5ED1ED71C1E880900F8F27F /* Resources */, 198 | ); 199 | buildRules = ( 200 | ); 201 | dependencies = ( 202 | C5ED1EDB1C1E880900F8F27F /* PBXTargetDependency */, 203 | ); 204 | name = PlaybackButtonUITests; 205 | productName = PlaybackButtonUITests; 206 | productReference = C5ED1ED91C1E880900F8F27F /* PlaybackButtonUITests.xctest */; 207 | productType = "com.apple.product-type.bundle.ui-testing"; 208 | }; 209 | /* End PBXNativeTarget section */ 210 | 211 | /* Begin PBXProject section */ 212 | C5ED1EB21C1E880900F8F27F /* Project object */ = { 213 | isa = PBXProject; 214 | attributes = { 215 | LastSwiftUpdateCheck = 0720; 216 | LastUpgradeCheck = 0800; 217 | ORGANIZATIONNAME = dekatotoro; 218 | TargetAttributes = { 219 | C5ED1EB91C1E880900F8F27F = { 220 | CreatedOnToolsVersion = 7.2; 221 | LastSwiftMigration = 0800; 222 | }; 223 | C5ED1ECD1C1E880900F8F27F = { 224 | CreatedOnToolsVersion = 7.2; 225 | LastSwiftMigration = 0800; 226 | TestTargetID = C5ED1EB91C1E880900F8F27F; 227 | }; 228 | C5ED1ED81C1E880900F8F27F = { 229 | CreatedOnToolsVersion = 7.2; 230 | LastSwiftMigration = 0800; 231 | TestTargetID = C5ED1EB91C1E880900F8F27F; 232 | }; 233 | }; 234 | }; 235 | buildConfigurationList = C5ED1EB51C1E880900F8F27F /* Build configuration list for PBXProject "PlaybackButton" */; 236 | compatibilityVersion = "Xcode 3.2"; 237 | developmentRegion = English; 238 | hasScannedForEncodings = 0; 239 | knownRegions = ( 240 | en, 241 | Base, 242 | ); 243 | mainGroup = C5ED1EB11C1E880900F8F27F; 244 | productRefGroup = C5ED1EBB1C1E880900F8F27F /* Products */; 245 | projectDirPath = ""; 246 | projectRoot = ""; 247 | targets = ( 248 | C5ED1EB91C1E880900F8F27F /* PlaybackButton */, 249 | C5ED1ECD1C1E880900F8F27F /* PlaybackButtonTests */, 250 | C5ED1ED81C1E880900F8F27F /* PlaybackButtonUITests */, 251 | ); 252 | }; 253 | /* End PBXProject section */ 254 | 255 | /* Begin PBXResourcesBuildPhase section */ 256 | C5ED1EB81C1E880900F8F27F /* Resources */ = { 257 | isa = PBXResourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | C5ED1EC81C1E880900F8F27F /* LaunchScreen.storyboard in Resources */, 261 | C5ED1EC51C1E880900F8F27F /* Assets.xcassets in Resources */, 262 | C5ED1EC31C1E880900F8F27F /* Main.storyboard in Resources */, 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | C5ED1ECC1C1E880900F8F27F /* Resources */ = { 267 | isa = PBXResourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | runOnlyForDeploymentPostprocessing = 0; 272 | }; 273 | C5ED1ED71C1E880900F8F27F /* Resources */ = { 274 | isa = PBXResourcesBuildPhase; 275 | buildActionMask = 2147483647; 276 | files = ( 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXResourcesBuildPhase section */ 281 | 282 | /* Begin PBXSourcesBuildPhase section */ 283 | C5ED1EB61C1E880900F8F27F /* Sources */ = { 284 | isa = PBXSourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | C5ED1EF01C1E890500F8F27F /* PlaybackButton.swift in Sources */, 288 | C5ED1EC01C1E880900F8F27F /* ViewController.swift in Sources */, 289 | C5D0432D1C367E580088850C /* String.swift in Sources */, 290 | C5ED1EBE1C1E880900F8F27F /* AppDelegate.swift in Sources */, 291 | C5D0432E1C367E580088850C /* UIColor.swift in Sources */, 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | C5ED1ECA1C1E880900F8F27F /* Sources */ = { 296 | isa = PBXSourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | C5ED1ED31C1E880900F8F27F /* PlaybackButtonTests.swift in Sources */, 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | C5ED1ED51C1E880900F8F27F /* Sources */ = { 304 | isa = PBXSourcesBuildPhase; 305 | buildActionMask = 2147483647; 306 | files = ( 307 | C5ED1EDE1C1E880900F8F27F /* PlaybackButtonUITests.swift in Sources */, 308 | ); 309 | runOnlyForDeploymentPostprocessing = 0; 310 | }; 311 | /* End PBXSourcesBuildPhase section */ 312 | 313 | /* Begin PBXTargetDependency section */ 314 | C5ED1ED01C1E880900F8F27F /* PBXTargetDependency */ = { 315 | isa = PBXTargetDependency; 316 | target = C5ED1EB91C1E880900F8F27F /* PlaybackButton */; 317 | targetProxy = C5ED1ECF1C1E880900F8F27F /* PBXContainerItemProxy */; 318 | }; 319 | C5ED1EDB1C1E880900F8F27F /* PBXTargetDependency */ = { 320 | isa = PBXTargetDependency; 321 | target = C5ED1EB91C1E880900F8F27F /* PlaybackButton */; 322 | targetProxy = C5ED1EDA1C1E880900F8F27F /* PBXContainerItemProxy */; 323 | }; 324 | /* End PBXTargetDependency section */ 325 | 326 | /* Begin PBXVariantGroup section */ 327 | C5ED1EC11C1E880900F8F27F /* Main.storyboard */ = { 328 | isa = PBXVariantGroup; 329 | children = ( 330 | C5ED1EC21C1E880900F8F27F /* Base */, 331 | ); 332 | name = Main.storyboard; 333 | sourceTree = ""; 334 | }; 335 | C5ED1EC61C1E880900F8F27F /* LaunchScreen.storyboard */ = { 336 | isa = PBXVariantGroup; 337 | children = ( 338 | C5ED1EC71C1E880900F8F27F /* Base */, 339 | ); 340 | name = LaunchScreen.storyboard; 341 | sourceTree = ""; 342 | }; 343 | /* End PBXVariantGroup section */ 344 | 345 | /* Begin XCBuildConfiguration section */ 346 | C5ED1EE01C1E880900F8F27F /* Debug */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ALWAYS_SEARCH_USER_PATHS = NO; 350 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 351 | CLANG_CXX_LIBRARY = "libc++"; 352 | CLANG_ENABLE_MODULES = YES; 353 | CLANG_ENABLE_OBJC_ARC = YES; 354 | CLANG_WARN_BOOL_CONVERSION = YES; 355 | CLANG_WARN_CONSTANT_CONVERSION = YES; 356 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 357 | CLANG_WARN_EMPTY_BODY = YES; 358 | CLANG_WARN_ENUM_CONVERSION = YES; 359 | CLANG_WARN_INFINITE_RECURSION = YES; 360 | CLANG_WARN_INT_CONVERSION = YES; 361 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 362 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = NO; 367 | DEBUG_INFORMATION_FORMAT = dwarf; 368 | ENABLE_STRICT_OBJC_MSGSEND = YES; 369 | ENABLE_TESTABILITY = YES; 370 | GCC_C_LANGUAGE_STANDARD = gnu99; 371 | GCC_DYNAMIC_NO_PIC = NO; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_OPTIMIZATION_LEVEL = 0; 374 | GCC_PREPROCESSOR_DEFINITIONS = ( 375 | "DEBUG=1", 376 | "$(inherited)", 377 | ); 378 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 379 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 380 | GCC_WARN_UNDECLARED_SELECTOR = YES; 381 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 382 | GCC_WARN_UNUSED_FUNCTION = YES; 383 | GCC_WARN_UNUSED_VARIABLE = YES; 384 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 385 | MTL_ENABLE_DEBUG_INFO = YES; 386 | ONLY_ACTIVE_ARCH = YES; 387 | SDKROOT = iphoneos; 388 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 389 | }; 390 | name = Debug; 391 | }; 392 | C5ED1EE11C1E880900F8F27F /* Release */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_SEARCH_USER_PATHS = NO; 396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 397 | CLANG_CXX_LIBRARY = "libc++"; 398 | CLANG_ENABLE_MODULES = YES; 399 | CLANG_ENABLE_OBJC_ARC = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_CONSTANT_CONVERSION = YES; 402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INFINITE_RECURSION = YES; 406 | CLANG_WARN_INT_CONVERSION = YES; 407 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 408 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 409 | CLANG_WARN_UNREACHABLE_CODE = YES; 410 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 411 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 412 | COPY_PHASE_STRIP = NO; 413 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 414 | ENABLE_NS_ASSERTIONS = NO; 415 | ENABLE_STRICT_OBJC_MSGSEND = YES; 416 | GCC_C_LANGUAGE_STANDARD = gnu99; 417 | GCC_NO_COMMON_BLOCKS = YES; 418 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 419 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 420 | GCC_WARN_UNDECLARED_SELECTOR = YES; 421 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 422 | GCC_WARN_UNUSED_FUNCTION = YES; 423 | GCC_WARN_UNUSED_VARIABLE = YES; 424 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 425 | MTL_ENABLE_DEBUG_INFO = NO; 426 | SDKROOT = iphoneos; 427 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 428 | VALIDATE_PRODUCT = YES; 429 | }; 430 | name = Release; 431 | }; 432 | C5ED1EE31C1E880900F8F27F /* Debug */ = { 433 | isa = XCBuildConfiguration; 434 | buildSettings = { 435 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 436 | INFOPLIST_FILE = PlaybackButton/Info.plist; 437 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 438 | PRODUCT_BUNDLE_IDENTIFIER = com.dekatotoro.PlaybackButton; 439 | PRODUCT_NAME = "$(TARGET_NAME)"; 440 | SWIFT_VERSION = 3.0; 441 | }; 442 | name = Debug; 443 | }; 444 | C5ED1EE41C1E880900F8F27F /* Release */ = { 445 | isa = XCBuildConfiguration; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | INFOPLIST_FILE = PlaybackButton/Info.plist; 449 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 450 | PRODUCT_BUNDLE_IDENTIFIER = com.dekatotoro.PlaybackButton; 451 | PRODUCT_NAME = "$(TARGET_NAME)"; 452 | SWIFT_VERSION = 3.0; 453 | }; 454 | name = Release; 455 | }; 456 | C5ED1EE61C1E880900F8F27F /* Debug */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | BUNDLE_LOADER = "$(TEST_HOST)"; 460 | INFOPLIST_FILE = PlaybackButtonTests/Info.plist; 461 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 462 | PRODUCT_BUNDLE_IDENTIFIER = com.dekatotoro.PlaybackButtonTests; 463 | PRODUCT_NAME = "$(TARGET_NAME)"; 464 | SWIFT_VERSION = 3.0; 465 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlaybackButton.app/PlaybackButton"; 466 | }; 467 | name = Debug; 468 | }; 469 | C5ED1EE71C1E880900F8F27F /* Release */ = { 470 | isa = XCBuildConfiguration; 471 | buildSettings = { 472 | BUNDLE_LOADER = "$(TEST_HOST)"; 473 | INFOPLIST_FILE = PlaybackButtonTests/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 475 | PRODUCT_BUNDLE_IDENTIFIER = com.dekatotoro.PlaybackButtonTests; 476 | PRODUCT_NAME = "$(TARGET_NAME)"; 477 | SWIFT_VERSION = 3.0; 478 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlaybackButton.app/PlaybackButton"; 479 | }; 480 | name = Release; 481 | }; 482 | C5ED1EE91C1E880900F8F27F /* Debug */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | INFOPLIST_FILE = PlaybackButtonUITests/Info.plist; 486 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 487 | PRODUCT_BUNDLE_IDENTIFIER = com.dekatotoro.PlaybackButtonUITests; 488 | PRODUCT_NAME = "$(TARGET_NAME)"; 489 | SWIFT_VERSION = 3.0; 490 | TEST_TARGET_NAME = PlaybackButton; 491 | USES_XCTRUNNER = YES; 492 | }; 493 | name = Debug; 494 | }; 495 | C5ED1EEA1C1E880900F8F27F /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | INFOPLIST_FILE = PlaybackButtonUITests/Info.plist; 499 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 500 | PRODUCT_BUNDLE_IDENTIFIER = com.dekatotoro.PlaybackButtonUITests; 501 | PRODUCT_NAME = "$(TARGET_NAME)"; 502 | SWIFT_VERSION = 3.0; 503 | TEST_TARGET_NAME = PlaybackButton; 504 | USES_XCTRUNNER = YES; 505 | }; 506 | name = Release; 507 | }; 508 | /* End XCBuildConfiguration section */ 509 | 510 | /* Begin XCConfigurationList section */ 511 | C5ED1EB51C1E880900F8F27F /* Build configuration list for PBXProject "PlaybackButton" */ = { 512 | isa = XCConfigurationList; 513 | buildConfigurations = ( 514 | C5ED1EE01C1E880900F8F27F /* Debug */, 515 | C5ED1EE11C1E880900F8F27F /* Release */, 516 | ); 517 | defaultConfigurationIsVisible = 0; 518 | defaultConfigurationName = Release; 519 | }; 520 | C5ED1EE21C1E880900F8F27F /* Build configuration list for PBXNativeTarget "PlaybackButton" */ = { 521 | isa = XCConfigurationList; 522 | buildConfigurations = ( 523 | C5ED1EE31C1E880900F8F27F /* Debug */, 524 | C5ED1EE41C1E880900F8F27F /* Release */, 525 | ); 526 | defaultConfigurationIsVisible = 0; 527 | defaultConfigurationName = Release; 528 | }; 529 | C5ED1EE51C1E880900F8F27F /* Build configuration list for PBXNativeTarget "PlaybackButtonTests" */ = { 530 | isa = XCConfigurationList; 531 | buildConfigurations = ( 532 | C5ED1EE61C1E880900F8F27F /* Debug */, 533 | C5ED1EE71C1E880900F8F27F /* Release */, 534 | ); 535 | defaultConfigurationIsVisible = 0; 536 | defaultConfigurationName = Release; 537 | }; 538 | C5ED1EE81C1E880900F8F27F /* Build configuration list for PBXNativeTarget "PlaybackButtonUITests" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | C5ED1EE91C1E880900F8F27F /* Debug */, 542 | C5ED1EEA1C1E880900F8F27F /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | defaultConfigurationName = Release; 546 | }; 547 | /* End XCConfigurationList section */ 548 | }; 549 | rootObject = C5ED1EB21C1E880900F8F27F /* Project object */; 550 | } 551 | -------------------------------------------------------------------------------- /PlaybackButton.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PlaybackButton.xcodeproj/xcuserdata/a12447.xcuserdatad/xcschemes/PlaybackButton.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /PlaybackButton.xcodeproj/xcuserdata/a12447.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PlaybackButton.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | C5ED1EB91C1E880900F8F27F 16 | 17 | primary 18 | 19 | 20 | C5ED1ECD1C1E880900F8F27F 21 | 22 | primary 23 | 24 | 25 | C5ED1ED81C1E880900F8F27F 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /PlaybackButton/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PlaybackButton 4 | // 5 | // Created by Yuji Hato on 12/14/15. 6 | // Copyright © 2015 dekatotoro. 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: [UIApplicationLaunchOptionsKey: Any]?) -> 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 | -------------------------------------------------------------------------------- /PlaybackButton/Assets.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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /PlaybackButton/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PlaybackButton/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 33 | 46 | 54 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /PlaybackButton/Extensions/String.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String.swift 3 | // PlaybackButton 4 | // 5 | // Created by Yuji Hato on 1/1/16. 6 | // Copyright © 2016 dekatotoro. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension String { 12 | 13 | var length: Int { 14 | return self.characters.count 15 | } 16 | 17 | func substring(_ from: Int) -> String { 18 | return self.substring(from: self.characters.index(self.startIndex, offsetBy: from)) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PlaybackButton/Extensions/UIColor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor.swift 3 | // PlaybackButton 4 | // 5 | // Created by Yuji Hato on 1/1/16. 6 | // Copyright © 2016 dekatotoro. All rights reserved. 7 | // 8 | import UIKit 9 | 10 | extension UIColor { 11 | convenience init(hex: String, alpha: CGFloat) { 12 | var hexWithoutSymbol = hex 13 | if hexWithoutSymbol.hasPrefix("#") { 14 | hexWithoutSymbol = hex.substring(1) 15 | } 16 | 17 | let scanner = Scanner(string: hexWithoutSymbol) 18 | var hexInt:UInt32 = 0x0 19 | scanner.scanHexInt32(&hexInt) 20 | 21 | var r:UInt32!, g:UInt32!, b:UInt32! 22 | switch (hexWithoutSymbol.length) { 23 | case 3: // #RGB 24 | r = ((hexInt >> 4) & 0xf0 | (hexInt >> 8) & 0x0f) 25 | g = ((hexInt >> 0) & 0xf0 | (hexInt >> 4) & 0x0f) 26 | b = ((hexInt << 4) & 0xf0 | hexInt & 0x0f) 27 | break; 28 | case 6: // #RRGGBB 29 | r = (hexInt >> 16) & 0xff 30 | g = (hexInt >> 8) & 0xff 31 | b = hexInt & 0xff 32 | break; 33 | default: 34 | // :ERROR 35 | break; 36 | } 37 | 38 | self.init( 39 | red: (CGFloat(r)/255), 40 | green: (CGFloat(g)/255), 41 | blue: (CGFloat(b)/255), 42 | alpha:alpha) 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /PlaybackButton/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 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 | 40 | 41 | -------------------------------------------------------------------------------- /PlaybackButton/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // PlaybackButton 4 | // 5 | // Created by Yuji Hato on 12/14/15. 6 | // Copyright © 2015 dekatotoro. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | var playbackButton1: PlaybackButton! 14 | @IBOutlet weak var playbackButton2: PlaybackButton! 15 | @IBOutlet weak var playbackButton3: PlaybackButton! 16 | @IBOutlet weak var playbackButton4: PlaybackButton! 17 | @IBOutlet weak var playbackButton5: PlaybackButton! 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | // playbackButton1 23 | self.playbackButton1 = PlaybackButton(frame: CGRect(x: 0, y:20, width: 100, height: 100 )) 24 | self.playbackButton1.contentEdgeInsets = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) 25 | self.playbackButton1.adjustMargin = 1 26 | self.playbackButton1.backgroundColor = UIColor.clear 27 | self.playbackButton1.setButtonColor(UIColor(hex: "2c3e50", alpha: 1.0)) 28 | self.playbackButton1.addTarget(self, action: #selector(ViewController.didTapPlaybackButton1(_:)), for: UIControlEvents.touchUpInside) 29 | self.view.addSubview(self.playbackButton1) 30 | 31 | // playbackButton2 32 | self.playbackButton2.layer.cornerRadius = 24.0 33 | self.playbackButton2.duration = 0.4 34 | self.playbackButton2.layer.borderColor = UIColor.white.cgColor 35 | self.playbackButton2.layer.borderWidth = 2.0 36 | 37 | // playbackButton3 38 | self.playbackButton3.layer.cornerRadius = self.playbackButton3.frame.size.height / 2 39 | self.playbackButton3.layer.borderColor = UIColor.white.cgColor 40 | self.playbackButton3.layer.borderWidth = 2.0 41 | self.playbackButton3.setButtonColor(UIColor(hex: "95a5a6", alpha: 1.0), buttonState: PlaybackButtonState.pending) 42 | 43 | // playbackButton4 44 | self.playbackButton4.layer.cornerRadius = self.playbackButton4.frame.size.height / 2 45 | self.playbackButton4.contentEdgeInsets = UIEdgeInsets(top: 16, left: 18, bottom: 16, right: 18) 46 | self.playbackButton4.adjustMargin = 1 47 | self.playbackButton4.layer.borderColor = UIColor.white.cgColor 48 | self.playbackButton4.layer.borderWidth = 2.0 49 | self.playbackButton4.setButtonColor(UIColor(hex: "95a5a6", alpha: 1.0), buttonState: PlaybackButtonState.pending) 50 | 51 | // playbackButton5 52 | self.playbackButton5.layer.cornerRadius = self.playbackButton5.frame.size.height / 2 53 | self.playbackButton5.layer.borderColor = UIColor(hex: "2c3e50", alpha: 1.0).cgColor 54 | self.playbackButton5.layer.borderWidth = 5.0 55 | self.playbackButton5.duration = 0.3 56 | self.playbackButton5.adjustMargin = 1 57 | } 58 | 59 | override func didReceiveMemoryWarning() { 60 | super.didReceiveMemoryWarning() 61 | } 62 | 63 | 64 | func didTapPlaybackButton1(_ sender: AnyObject) { 65 | if self.playbackButton1.buttonState == .playing { 66 | self.playbackButton1.setButtonState(.pausing, animated: true) 67 | } else if self.playbackButton1.buttonState == .pausing { 68 | self.playbackButton1.setButtonState(.playing, animated: true) 69 | } 70 | } 71 | 72 | @IBAction func didTapPlaybackButton2(_ sender: AnyObject) { 73 | if self.playbackButton2.buttonState == .playing { 74 | self.playbackButton2.setButtonState(.pausing, animated: true) 75 | } else if self.playbackButton2.buttonState == .pausing { 76 | self.playbackButton2.setButtonState(.playing, animated: true) 77 | } 78 | } 79 | 80 | @IBAction func didTapPlaybackButton3(_ sender: AnyObject) { 81 | if self.playbackButton3.buttonState == .playing { 82 | self.playbackButton3.setButtonState(.pending, animated: false) 83 | } else if self.playbackButton3.buttonState == .pausing { 84 | self.playbackButton3.setButtonState(.playing, animated: false) 85 | } else if self.playbackButton3.buttonState == .pending { 86 | self.playbackButton3.setButtonState(.pausing, animated: false) 87 | } 88 | } 89 | 90 | @IBAction func didTapPlaybackButton4(_ sender: AnyObject) { 91 | if self.playbackButton4.buttonState == .playing { 92 | self.playbackButton4.setButtonState(.pending, animated: true) 93 | } else if self.playbackButton4.buttonState == .pausing { 94 | self.playbackButton4.setButtonState(.playing, animated: true) 95 | } else if self.playbackButton4.buttonState == .pending { 96 | self.playbackButton4.setButtonState(.pausing, animated: true) 97 | } 98 | } 99 | 100 | @IBAction func didTapPlaybackButton5(_ sender: AnyObject) { 101 | if self.playbackButton5.buttonState == .playing { 102 | self.playbackButton5.setButtonState(.pausing, animated: true) 103 | } else if self.playbackButton5.buttonState == .pausing { 104 | self.playbackButton5.setButtonState(.playing, animated: true) 105 | } 106 | } 107 | } 108 | 109 | -------------------------------------------------------------------------------- /PlaybackButtonTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PlaybackButtonTests/PlaybackButtonTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlaybackButtonTests.swift 3 | // PlaybackButtonTests 4 | // 5 | // Created by Yuji Hato on 12/14/15. 6 | // Copyright © 2015 dekatotoro. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import PlaybackButton 11 | 12 | class PlaybackButtonTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /PlaybackButtonUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /PlaybackButtonUITests/PlaybackButtonUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlaybackButtonUITests.swift 3 | // PlaybackButtonUITests 4 | // 5 | // Created by Yuji Hato on 12/14/15. 6 | // Copyright © 2015 dekatotoro. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class PlaybackButtonUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PlaybackButton 2 | ======================== 3 | 4 | [![Platform](http://img.shields.io/badge/platform-ios-blue.svg?style=flat 5 | )](https://developer.apple.com/iphone/index.action) 6 | [![Language](http://img.shields.io/badge/language-swift-brightgreen.svg?style=flat 7 | )](https://developer.apple.com/swift) 8 | [![License](http://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat 9 | )](http://mit-license.org) 10 | [![Issues](https://img.shields.io/github/issues/dekatotoro/PlaybackButton.svg?style=flat 11 | )](https://github.com/dekatotoro/PlaybackButton/issues?state=open) 12 | 13 | 14 | 15 | iOS animation playback button inspired by the playback button of YouTube for web. 16 | 17 | ![sample](Screenshots/PlaybackButton.gif) 18 | 19 | ##Installation 20 | 21 | ####CocoaPods 22 | ``` 23 | pod 'PlaybackButton' 24 | ``` 25 | 26 | 27 | ####Manually 28 | Add the `PlaybackButton.swift` file to your project. 29 | 30 | ##Usage 31 | 32 | ###Setup 33 | 34 | Add `import PlaybackButton` in your file 35 | 36 | In your ViewController: 37 | 38 | ```swift 39 | @IBOutlet weak var playbackButton: PlaybackButton! 40 | 41 | self.playbackButton.layer.cornerRadius = self.playbackButton.frame.size.height / 2 42 | self.playbackButton.layer.borderWidth = 2.0 43 | self.playbackButton.adjustMargin = 1 44 | self.playbackButton2.duration = 0.3 // animation duration default 0.24 45 | 46 | @IBAction func didTapPlaybackButton(sender: AnyObject) { 47 | if self.playbackButton.buttonState == .Playing { 48 | self.playbackButton.setButtonState(.Pausing, animated: true) 49 | } else if self.playbackButton.buttonState == .Pausing { 50 | self.playbackButton.setButtonState(.Playing, animated: true) 51 | } 52 | } 53 | ``` 54 | 55 | ```swift 56 | var playbackButton: PlaybackButton! 57 | 58 | self.playbackButton = PlaybackButton(frame: CGRect(x: 0, y:20, width: 100, height: 100 )) 59 | self.playbackButton.contentEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) 60 | self.playbackButton.adjustMargin = 0 61 | self.playbackButton.addTarget(self, action: "didTapPlaybackButton:", forControlEvents: UIControlEvents.TouchUpInside) 62 | self.view.addSubview(self.playbackButton) 63 | 64 | func didTapPlaybackButton(sender: AnyObject) { 65 | if self.playbackButton.buttonState == .Playing { 66 | self.playbackButton.setButtonState(.Pausing, animated: true) 67 | } else if self.playbackButton.buttonState == .Pausing { 68 | self.playbackButton.setButtonState(.Playing, animated: true) 69 | } 70 | } 71 | ``` 72 | 73 | ``` 74 | note1: 75 | The position of PlaybackButton is based on top and left of ContentEdgeInsets. 76 | Please regulate it at the position where wants to locate it. 77 | ``` 78 | 79 | ``` 80 | note2: 81 | The value of adjustMargin, please appoint 0-1. 82 | The default is 0. 83 | The left position of play becomes same as pause when adjustMargin is 1. 84 | It is suitable to place PlaybackButton in the middle of view in the case of 0. 85 | ``` 86 | 87 | ## Requirements 88 | Requires Swift2.0 and iOS 8.0 and ARC. 89 | If you want to use even iOS7.0, please to import the code directly. 90 | 91 | ## Features 92 | - Highly customizable 93 | - Complete example 94 | 95 | 96 | ## Contributing 97 | 98 | Forks, patches and other feedback are welcome. 99 | 100 | ## Creator 101 | 102 | [Yuji Hato](https://github.com/dekatotoro) 103 | [Blog](http://buzzmemo.blogspot.jp/) 104 | 105 | ## License 106 | 107 | PlaybackButton is available under the MIT license. See the LICENSE file for more info. 108 | -------------------------------------------------------------------------------- /Screenshots/PlaybackButton.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dekatotoro/PlaybackButton/77748ba1d22c4aed8870b7aaa26a148a8a50e7a3/Screenshots/PlaybackButton.gif -------------------------------------------------------------------------------- /Source/PlaybackButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PlaybackButton.swift 3 | // PlaybackButton 4 | // 5 | // Created by Yuji Hato on 1/1/16. 6 | // Copyright © 2016 dekatotoro. All rights reserved. 7 | // 8 | 9 | 10 | import UIKit 11 | 12 | @objc public enum PlaybackButtonState : Int { 13 | case none = 0 14 | case pausing 15 | case playing 16 | case pending 17 | 18 | public var value: CGFloat { 19 | switch self { 20 | case .none: 21 | return 0.0 22 | case .pausing: 23 | return 1.0 24 | case .playing: 25 | return 0.0 26 | case .pending: 27 | return 1.0 28 | } 29 | } 30 | 31 | public func color(_ layer: PlaybackLayer) -> CGColor { 32 | switch self { 33 | case .none: 34 | return UIColor.white.cgColor 35 | case .pausing: 36 | return layer.pausingColor.cgColor 37 | case .playing: 38 | return layer.playingColor.cgColor 39 | case .pending: 40 | return layer.pendingColor.cgColor 41 | } 42 | } 43 | } 44 | 45 | @objc open class PlaybackLayer: CALayer { 46 | 47 | fileprivate static let kAnimationKey = "playbackValue" 48 | fileprivate static let kAnimationIdentifier = "playbackLayerAnimation" 49 | 50 | open var adjustMarginValue: CGFloat = 0 51 | open var contentEdgeInsets = UIEdgeInsets.zero 52 | open var buttonState = PlaybackButtonState.pausing 53 | open var playbackValue: CGFloat = 1.0 { 54 | didSet { 55 | setNeedsDisplay() 56 | } 57 | } 58 | open var pausingColor = UIColor.white 59 | open var playingColor = UIColor.white 60 | open var pendingColor = UIColor.white 61 | open var playbackAnimationDuration: CFTimeInterval = PlaybackButton.kDefaultDuration 62 | 63 | override init() { 64 | super.init() 65 | } 66 | 67 | override init(layer: Any) { 68 | super.init(layer: layer) 69 | if let playbackLayer = layer as? PlaybackLayer { 70 | self.adjustMarginValue = playbackLayer.adjustMarginValue 71 | self.contentEdgeInsets = playbackLayer.contentEdgeInsets 72 | self.buttonState = playbackLayer.buttonState 73 | self.playbackValue = playbackLayer.playbackValue 74 | self.playingColor = playbackLayer.playingColor 75 | self.pausingColor = playbackLayer.pausingColor 76 | self.pendingColor = playbackLayer.pendingColor 77 | } 78 | } 79 | 80 | public required init?(coder aDecoder: NSCoder) { 81 | super.init(coder: aDecoder) 82 | } 83 | 84 | deinit { 85 | self.removeAllAnimations() 86 | } 87 | 88 | open func setButtonState(_ buttonState: PlaybackButtonState, animated: Bool) { 89 | if self.buttonState == buttonState { 90 | return 91 | } 92 | self.buttonState = buttonState 93 | 94 | if animated { 95 | if self.animation(forKey: PlaybackLayer.kAnimationIdentifier) != nil { 96 | self.removeAnimation(forKey: PlaybackLayer.kAnimationIdentifier) 97 | } 98 | 99 | let fromValue: CGFloat = self.playbackValue 100 | let toValue: CGFloat = buttonState.value 101 | 102 | let animation = CABasicAnimation(keyPath: PlaybackLayer.kAnimationKey) 103 | animation.fromValue = fromValue 104 | animation.toValue = toValue 105 | animation.duration = self.playbackAnimationDuration 106 | animation.isRemovedOnCompletion = true 107 | animation.fillMode = kCAFillModeForwards 108 | animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) 109 | animation.delegate = self 110 | self.add(animation, forKey: PlaybackLayer.kAnimationIdentifier) 111 | } else { 112 | self.playbackValue = buttonState.value 113 | } 114 | } 115 | 116 | open override class func needsDisplay(forKey key: String) -> Bool { 117 | if key == PlaybackLayer.kAnimationKey { 118 | return true 119 | } 120 | return CALayer.needsDisplay(forKey: key) 121 | } 122 | 123 | open override func draw(in context: CGContext) { 124 | switch self.buttonState { 125 | case .none: 126 | return 127 | case .pausing, .pending, .playing: 128 | 129 | let rect = context.boundingBoxOfClipPath 130 | let baseWidth = rect.width 131 | let baseHeight = rect.height 132 | let topMargin: CGFloat = self.contentEdgeInsets.top 133 | let leftMargin: CGFloat = self.contentEdgeInsets.left 134 | 135 | let drawHalfWidth: CGFloat = (baseWidth - leftMargin * 2) / 2.0 136 | let drawQuarterWidth: CGFloat = drawHalfWidth / 2.0 137 | let subtractWidth: CGFloat = drawHalfWidth - drawQuarterWidth 138 | let width: CGFloat = drawQuarterWidth + subtractWidth * self.playbackValue 139 | 140 | let playingMargin: CGFloat = drawQuarterWidth / 2.0 * self.adjustMarginValue 141 | let pausingMargin: CGFloat = drawQuarterWidth / 2.0 142 | let subtractMargin: CGFloat = playingMargin - pausingMargin 143 | let adjustMargin: CGFloat = pausingMargin + subtractMargin * self.playbackValue 144 | 145 | let height: CGFloat = baseHeight - topMargin * 2 146 | let h1: CGFloat = height / 4.0 * self.playbackValue 147 | let h2: CGFloat = height / 2.0 * self.playbackValue 148 | 149 | context.move(to: CGPoint(x: leftMargin + adjustMargin, y: topMargin)) 150 | context.addLine(to: CGPoint(x: leftMargin + adjustMargin + width, y: topMargin + h1)) 151 | context.addLine(to: CGPoint(x: leftMargin + adjustMargin + width, y: topMargin + height - h1)) 152 | context.addLine(to: CGPoint(x: leftMargin + adjustMargin, y: topMargin + height)) 153 | 154 | context.move(to: CGPoint(x: leftMargin + drawHalfWidth + adjustMargin, y: topMargin + h1)) 155 | context.addLine(to: CGPoint(x: leftMargin + drawHalfWidth + adjustMargin + width, y: topMargin + h2)) 156 | context.addLine(to: CGPoint(x: leftMargin + drawHalfWidth + adjustMargin + width, y: topMargin + height - h2)) 157 | context.addLine(to: CGPoint(x: leftMargin + drawHalfWidth + adjustMargin, y: topMargin + height - h1)) 158 | 159 | context.setFillColor(self.buttonState.color(self)) 160 | context.fillPath() 161 | } 162 | } 163 | } 164 | 165 | extension PlaybackLayer: CAAnimationDelegate { 166 | 167 | open func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { 168 | if flag { 169 | if self.animation(forKey: PlaybackLayer.kAnimationIdentifier) != nil { 170 | self.removeAnimation(forKey: PlaybackLayer.kAnimationIdentifier) 171 | } 172 | if let toValue : CGFloat = anim.value(forKey: "toValue") as? CGFloat { 173 | self.playbackValue = toValue 174 | } 175 | } 176 | } 177 | } 178 | 179 | @objc open class PlaybackButton : UIButton { 180 | 181 | static let kDefaultDuration: CFTimeInterval = 0.24 182 | open var playbackLayer: PlaybackLayer? 183 | open var duration: CFTimeInterval = PlaybackButton.kDefaultDuration { 184 | didSet { 185 | self.playbackLayer?.playbackAnimationDuration = self.duration 186 | } 187 | } 188 | 189 | open var buttonState: PlaybackButtonState { 190 | return self.playbackLayer?.buttonState ?? PlaybackButtonState.pausing 191 | } 192 | 193 | open override var contentEdgeInsets: UIEdgeInsets { 194 | didSet { 195 | self.playbackLayer?.contentEdgeInsets = self.contentEdgeInsets 196 | } 197 | } 198 | 199 | open var adjustMargin: CGFloat = 1 { 200 | didSet { 201 | self.playbackLayer?.adjustMarginValue = self.adjustMargin 202 | } 203 | } 204 | 205 | override init(frame: CGRect) { 206 | super.init(frame: frame) 207 | self.addPlaybackLayer() 208 | } 209 | 210 | public required init?(coder aDecoder: NSCoder) { 211 | super.init(coder: aDecoder) 212 | self.addPlaybackLayer() 213 | } 214 | 215 | open override func awakeFromNib() { 216 | super.awakeFromNib() 217 | } 218 | 219 | open func setButtonState(_ buttonState: PlaybackButtonState, animated: Bool) { 220 | self.playbackLayer?.setButtonState(buttonState, animated: animated) 221 | } 222 | 223 | open func setButtonColor(_ color: UIColor) { 224 | self.playbackLayer?.pausingColor = color 225 | self.playbackLayer?.playingColor = color 226 | self.playbackLayer?.pendingColor = color 227 | } 228 | 229 | open func setButtonColor(_ color: UIColor, buttonState: PlaybackButtonState) { 230 | switch buttonState { 231 | case .none: 232 | break 233 | case .pausing: 234 | self.playbackLayer?.pausingColor = color 235 | case .playing: 236 | self.playbackLayer?.playingColor = color 237 | case .pending: 238 | self.playbackLayer?.pendingColor = color 239 | } 240 | } 241 | 242 | fileprivate func addPlaybackLayer() { 243 | let playbackLayer = PlaybackLayer() 244 | playbackLayer.frame = self.bounds 245 | playbackLayer.adjustMarginValue = self.adjustMargin 246 | playbackLayer.contentEdgeInsets = self.contentEdgeInsets 247 | playbackLayer.playbackValue = PlaybackButtonState.pausing.value 248 | playbackLayer.pausingColor = self.tintColor 249 | playbackLayer.playingColor = self.tintColor 250 | playbackLayer.pendingColor = self.tintColor 251 | playbackLayer.playbackAnimationDuration = self.duration 252 | self.playbackLayer = playbackLayer 253 | self.layer.addSublayer(playbackLayer) 254 | } 255 | } 256 | --------------------------------------------------------------------------------