├── .gitignore ├── LICENSE ├── README.md ├── SDRecordButton-Demo ├── .DS_Store ├── SDRecordButton-Demo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── Seby.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Seby.xcuserdatad │ │ └── xcschemes │ │ ├── SDRecordButton-Demo.xcscheme │ │ └── xcschememanagement.plist ├── SDRecordButton-Demo │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── SDRecordButton-DemoTests │ ├── Info.plist │ └── SDRecordButton_DemoTests.m ├── SDRecordButton.podspec └── SDRecordButton ├── SDRecordButton.h └── SDRecordButton.m /.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 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Sebastian Dobrincu 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 |

2 | SDRecordButton 3 |

4 | 5 | 6 |

7 | 8 | Gitter 10 | 11 | 12 | MIT 14 | 15 | 16 | Community Approved 18 | 19 |

20 | 21 | # SDRecordButton 22 | An animated UIButton subclass, meant to be used as a recording button. Clean, highly customizable, lightweight. 23 | 24 | ## Add to your project 25 | 26 | There are 2 ways you can add SDRecordButton to your project: 27 | 28 | ### Manual installation 29 | 30 | Simply import the 'SDRecordButton' into your project then import the following in the class you want to use it: 31 | ```objective-c 32 | #import "SDRecordButton.h"; 33 | ``` 34 | ### Installation with CocoaPods 35 | 36 | CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SDRecordButton in your projects. See the "[Getting Started](http://guides.cocoapods.org/syntax/podfile.html)" guide for more information. 37 | 38 | ### Podfile 39 | ```ruby 40 | platform :ios, '6.0' 41 | pod "SDRecordButton", "~> "1.0" 42 | ``` 43 | 44 | ## Demo 45 | 46 |

47 | SDRecordButton 48 |

49 | 50 | ## Detecting recording state 51 | 52 | SDRecordButton makes use of UIButton's target property to detect state changes. In your view controller add the following targets to your button instance: 53 | ```objective-c 54 | [recordButton addTarget:self action:@selector(recording) forControlEvents:UIControlEventTouchDown]; 55 | [recordButton addTarget:self action:@selector(pausedRecording) forControlEvents:UIControlEventTouchUpInside]; 56 | [recordButton addTarget:self action:@selector(pausedRecording) forControlEvents:UIControlEventTouchUpOutside]; 57 | 58 | ``` 59 | For examples, check out the demo project. 60 | 61 | ## Available properties & methods 62 | ```objective-c 63 | buttonColor // UIColor - Main color of the button 64 | progressColor // UIColor - Color of the progress layer 65 | 66 | ``` 67 | ``` 68 | // Update loading progress of the button. From 0.0 to 1.0. 69 | - (void)setProgress:(CGFloat)progress; 70 | ``` 71 | 72 | ## License 73 | Usage is provided under the [MIT License](http://http//opensource.org/licenses/mit-license.php). See LICENSE for the full details. 74 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebyddd/SDRecordButton/f6575c4af8d5e3202c214fcbc125109f14ab14c0/SDRecordButton-Demo/.DS_Store -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9ABEDA0A1B7C7E3400C71B0B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABEDA091B7C7E3400C71B0B /* main.m */; }; 11 | 9ABEDA0D1B7C7E3400C71B0B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABEDA0C1B7C7E3400C71B0B /* AppDelegate.m */; }; 12 | 9ABEDA101B7C7E3400C71B0B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABEDA0F1B7C7E3400C71B0B /* ViewController.m */; }; 13 | 9ABEDA131B7C7E3400C71B0B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9ABEDA111B7C7E3400C71B0B /* Main.storyboard */; }; 14 | 9ABEDA151B7C7E3400C71B0B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9ABEDA141B7C7E3400C71B0B /* Images.xcassets */; }; 15 | 9ABEDA181B7C7E3400C71B0B /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9ABEDA161B7C7E3400C71B0B /* LaunchScreen.xib */; }; 16 | 9ABEDA241B7C7E3400C71B0B /* SDRecordButton_DemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABEDA231B7C7E3400C71B0B /* SDRecordButton_DemoTests.m */; }; 17 | 9ABEDA341B7C92D000C71B0B /* SDRecordButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABEDA331B7C92D000C71B0B /* SDRecordButton.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 9ABEDA1E1B7C7E3400C71B0B /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 9ABED9FC1B7C7E3400C71B0B /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 9ABEDA031B7C7E3400C71B0B; 26 | remoteInfo = "SDRecordButton-Demo"; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 9ABEDA041B7C7E3400C71B0B /* SDRecordButton-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SDRecordButton-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 9ABEDA081B7C7E3400C71B0B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 9ABEDA091B7C7E3400C71B0B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 34 | 9ABEDA0B1B7C7E3400C71B0B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 35 | 9ABEDA0C1B7C7E3400C71B0B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 36 | 9ABEDA0E1B7C7E3400C71B0B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 37 | 9ABEDA0F1B7C7E3400C71B0B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 38 | 9ABEDA121B7C7E3400C71B0B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 9ABEDA141B7C7E3400C71B0B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | 9ABEDA171B7C7E3400C71B0B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | 9ABEDA1D1B7C7E3400C71B0B /* SDRecordButton-DemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SDRecordButton-DemoTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 9ABEDA221B7C7E3400C71B0B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | 9ABEDA231B7C7E3400C71B0B /* SDRecordButton_DemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SDRecordButton_DemoTests.m; sourceTree = ""; }; 44 | 9ABEDA321B7C92D000C71B0B /* SDRecordButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDRecordButton.h; sourceTree = ""; }; 45 | 9ABEDA331B7C92D000C71B0B /* SDRecordButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDRecordButton.m; sourceTree = ""; }; 46 | /* End PBXFileReference section */ 47 | 48 | /* Begin PBXFrameworksBuildPhase section */ 49 | 9ABEDA011B7C7E3400C71B0B /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | 9ABEDA1A1B7C7E3400C71B0B /* Frameworks */ = { 57 | isa = PBXFrameworksBuildPhase; 58 | buildActionMask = 2147483647; 59 | files = ( 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 9ABED9FB1B7C7E3400C71B0B = { 67 | isa = PBXGroup; 68 | children = ( 69 | 9ABEDA061B7C7E3400C71B0B /* SDRecordButton-Demo */, 70 | 9ABEDA201B7C7E3400C71B0B /* SDRecordButton-DemoTests */, 71 | 9ABEDA051B7C7E3400C71B0B /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | 9ABEDA051B7C7E3400C71B0B /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 9ABEDA041B7C7E3400C71B0B /* SDRecordButton-Demo.app */, 79 | 9ABEDA1D1B7C7E3400C71B0B /* SDRecordButton-DemoTests.xctest */, 80 | ); 81 | name = Products; 82 | sourceTree = ""; 83 | }; 84 | 9ABEDA061B7C7E3400C71B0B /* SDRecordButton-Demo */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 9ABEDA311B7C92D000C71B0B /* SDRecordButton */, 88 | 9ABEDA0B1B7C7E3400C71B0B /* AppDelegate.h */, 89 | 9ABEDA0C1B7C7E3400C71B0B /* AppDelegate.m */, 90 | 9ABEDA0E1B7C7E3400C71B0B /* ViewController.h */, 91 | 9ABEDA0F1B7C7E3400C71B0B /* ViewController.m */, 92 | 9ABEDA111B7C7E3400C71B0B /* Main.storyboard */, 93 | 9ABEDA141B7C7E3400C71B0B /* Images.xcassets */, 94 | 9ABEDA161B7C7E3400C71B0B /* LaunchScreen.xib */, 95 | 9ABEDA071B7C7E3400C71B0B /* Supporting Files */, 96 | ); 97 | path = "SDRecordButton-Demo"; 98 | sourceTree = ""; 99 | }; 100 | 9ABEDA071B7C7E3400C71B0B /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 9ABEDA081B7C7E3400C71B0B /* Info.plist */, 104 | 9ABEDA091B7C7E3400C71B0B /* main.m */, 105 | ); 106 | name = "Supporting Files"; 107 | sourceTree = ""; 108 | }; 109 | 9ABEDA201B7C7E3400C71B0B /* SDRecordButton-DemoTests */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 9ABEDA231B7C7E3400C71B0B /* SDRecordButton_DemoTests.m */, 113 | 9ABEDA211B7C7E3400C71B0B /* Supporting Files */, 114 | ); 115 | path = "SDRecordButton-DemoTests"; 116 | sourceTree = ""; 117 | }; 118 | 9ABEDA211B7C7E3400C71B0B /* Supporting Files */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 9ABEDA221B7C7E3400C71B0B /* Info.plist */, 122 | ); 123 | name = "Supporting Files"; 124 | sourceTree = ""; 125 | }; 126 | 9ABEDA311B7C92D000C71B0B /* SDRecordButton */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 9ABEDA321B7C92D000C71B0B /* SDRecordButton.h */, 130 | 9ABEDA331B7C92D000C71B0B /* SDRecordButton.m */, 131 | ); 132 | name = SDRecordButton; 133 | path = ../../SDRecordButton; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | 9ABEDA031B7C7E3400C71B0B /* SDRecordButton-Demo */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = 9ABEDA271B7C7E3400C71B0B /* Build configuration list for PBXNativeTarget "SDRecordButton-Demo" */; 142 | buildPhases = ( 143 | 9ABEDA001B7C7E3400C71B0B /* Sources */, 144 | 9ABEDA011B7C7E3400C71B0B /* Frameworks */, 145 | 9ABEDA021B7C7E3400C71B0B /* Resources */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | ); 151 | name = "SDRecordButton-Demo"; 152 | productName = "SDRecordButton-Demo"; 153 | productReference = 9ABEDA041B7C7E3400C71B0B /* SDRecordButton-Demo.app */; 154 | productType = "com.apple.product-type.application"; 155 | }; 156 | 9ABEDA1C1B7C7E3400C71B0B /* SDRecordButton-DemoTests */ = { 157 | isa = PBXNativeTarget; 158 | buildConfigurationList = 9ABEDA2A1B7C7E3400C71B0B /* Build configuration list for PBXNativeTarget "SDRecordButton-DemoTests" */; 159 | buildPhases = ( 160 | 9ABEDA191B7C7E3400C71B0B /* Sources */, 161 | 9ABEDA1A1B7C7E3400C71B0B /* Frameworks */, 162 | 9ABEDA1B1B7C7E3400C71B0B /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | 9ABEDA1F1B7C7E3400C71B0B /* PBXTargetDependency */, 168 | ); 169 | name = "SDRecordButton-DemoTests"; 170 | productName = "SDRecordButton-DemoTests"; 171 | productReference = 9ABEDA1D1B7C7E3400C71B0B /* SDRecordButton-DemoTests.xctest */; 172 | productType = "com.apple.product-type.bundle.unit-test"; 173 | }; 174 | /* End PBXNativeTarget section */ 175 | 176 | /* Begin PBXProject section */ 177 | 9ABED9FC1B7C7E3400C71B0B /* Project object */ = { 178 | isa = PBXProject; 179 | attributes = { 180 | LastUpgradeCheck = 0800; 181 | ORGANIZATIONNAME = "Sebastian Dobrincu"; 182 | TargetAttributes = { 183 | 9ABEDA031B7C7E3400C71B0B = { 184 | CreatedOnToolsVersion = 6.4; 185 | }; 186 | 9ABEDA1C1B7C7E3400C71B0B = { 187 | CreatedOnToolsVersion = 6.4; 188 | TestTargetID = 9ABEDA031B7C7E3400C71B0B; 189 | }; 190 | }; 191 | }; 192 | buildConfigurationList = 9ABED9FF1B7C7E3400C71B0B /* Build configuration list for PBXProject "SDRecordButton-Demo" */; 193 | compatibilityVersion = "Xcode 3.2"; 194 | developmentRegion = English; 195 | hasScannedForEncodings = 0; 196 | knownRegions = ( 197 | en, 198 | Base, 199 | ); 200 | mainGroup = 9ABED9FB1B7C7E3400C71B0B; 201 | productRefGroup = 9ABEDA051B7C7E3400C71B0B /* Products */; 202 | projectDirPath = ""; 203 | projectRoot = ""; 204 | targets = ( 205 | 9ABEDA031B7C7E3400C71B0B /* SDRecordButton-Demo */, 206 | 9ABEDA1C1B7C7E3400C71B0B /* SDRecordButton-DemoTests */, 207 | ); 208 | }; 209 | /* End PBXProject section */ 210 | 211 | /* Begin PBXResourcesBuildPhase section */ 212 | 9ABEDA021B7C7E3400C71B0B /* Resources */ = { 213 | isa = PBXResourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | 9ABEDA131B7C7E3400C71B0B /* Main.storyboard in Resources */, 217 | 9ABEDA181B7C7E3400C71B0B /* LaunchScreen.xib in Resources */, 218 | 9ABEDA151B7C7E3400C71B0B /* Images.xcassets in Resources */, 219 | ); 220 | runOnlyForDeploymentPostprocessing = 0; 221 | }; 222 | 9ABEDA1B1B7C7E3400C71B0B /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXResourcesBuildPhase section */ 230 | 231 | /* Begin PBXSourcesBuildPhase section */ 232 | 9ABEDA001B7C7E3400C71B0B /* Sources */ = { 233 | isa = PBXSourcesBuildPhase; 234 | buildActionMask = 2147483647; 235 | files = ( 236 | 9ABEDA101B7C7E3400C71B0B /* ViewController.m in Sources */, 237 | 9ABEDA341B7C92D000C71B0B /* SDRecordButton.m in Sources */, 238 | 9ABEDA0D1B7C7E3400C71B0B /* AppDelegate.m in Sources */, 239 | 9ABEDA0A1B7C7E3400C71B0B /* main.m in Sources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | 9ABEDA191B7C7E3400C71B0B /* Sources */ = { 244 | isa = PBXSourcesBuildPhase; 245 | buildActionMask = 2147483647; 246 | files = ( 247 | 9ABEDA241B7C7E3400C71B0B /* SDRecordButton_DemoTests.m in Sources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXSourcesBuildPhase section */ 252 | 253 | /* Begin PBXTargetDependency section */ 254 | 9ABEDA1F1B7C7E3400C71B0B /* PBXTargetDependency */ = { 255 | isa = PBXTargetDependency; 256 | target = 9ABEDA031B7C7E3400C71B0B /* SDRecordButton-Demo */; 257 | targetProxy = 9ABEDA1E1B7C7E3400C71B0B /* PBXContainerItemProxy */; 258 | }; 259 | /* End PBXTargetDependency section */ 260 | 261 | /* Begin PBXVariantGroup section */ 262 | 9ABEDA111B7C7E3400C71B0B /* Main.storyboard */ = { 263 | isa = PBXVariantGroup; 264 | children = ( 265 | 9ABEDA121B7C7E3400C71B0B /* Base */, 266 | ); 267 | name = Main.storyboard; 268 | sourceTree = ""; 269 | }; 270 | 9ABEDA161B7C7E3400C71B0B /* LaunchScreen.xib */ = { 271 | isa = PBXVariantGroup; 272 | children = ( 273 | 9ABEDA171B7C7E3400C71B0B /* Base */, 274 | ); 275 | name = LaunchScreen.xib; 276 | sourceTree = ""; 277 | }; 278 | /* End PBXVariantGroup section */ 279 | 280 | /* Begin XCBuildConfiguration section */ 281 | 9ABEDA251B7C7E3400C71B0B /* Debug */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ALWAYS_SEARCH_USER_PATHS = NO; 285 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 286 | CLANG_CXX_LIBRARY = "libc++"; 287 | CLANG_ENABLE_MODULES = YES; 288 | CLANG_ENABLE_OBJC_ARC = YES; 289 | CLANG_WARN_BOOL_CONVERSION = YES; 290 | CLANG_WARN_CONSTANT_CONVERSION = YES; 291 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 292 | CLANG_WARN_EMPTY_BODY = YES; 293 | CLANG_WARN_ENUM_CONVERSION = YES; 294 | CLANG_WARN_INFINITE_RECURSION = YES; 295 | CLANG_WARN_INT_CONVERSION = YES; 296 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 297 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 298 | CLANG_WARN_UNREACHABLE_CODE = YES; 299 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 300 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 301 | COPY_PHASE_STRIP = NO; 302 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 303 | ENABLE_STRICT_OBJC_MSGSEND = YES; 304 | ENABLE_TESTABILITY = YES; 305 | GCC_C_LANGUAGE_STANDARD = gnu99; 306 | GCC_DYNAMIC_NO_PIC = NO; 307 | GCC_NO_COMMON_BLOCKS = YES; 308 | GCC_OPTIMIZATION_LEVEL = 0; 309 | GCC_PREPROCESSOR_DEFINITIONS = ( 310 | "DEBUG=1", 311 | "$(inherited)", 312 | ); 313 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 314 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 315 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 316 | GCC_WARN_UNDECLARED_SELECTOR = YES; 317 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 318 | GCC_WARN_UNUSED_FUNCTION = YES; 319 | GCC_WARN_UNUSED_VARIABLE = YES; 320 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 321 | MTL_ENABLE_DEBUG_INFO = YES; 322 | ONLY_ACTIVE_ARCH = YES; 323 | SDKROOT = iphoneos; 324 | }; 325 | name = Debug; 326 | }; 327 | 9ABEDA261B7C7E3400C71B0B /* Release */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ALWAYS_SEARCH_USER_PATHS = NO; 331 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 332 | CLANG_CXX_LIBRARY = "libc++"; 333 | CLANG_ENABLE_MODULES = YES; 334 | CLANG_ENABLE_OBJC_ARC = YES; 335 | CLANG_WARN_BOOL_CONVERSION = YES; 336 | CLANG_WARN_CONSTANT_CONVERSION = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INFINITE_RECURSION = YES; 341 | CLANG_WARN_INT_CONVERSION = YES; 342 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 343 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 344 | CLANG_WARN_UNREACHABLE_CODE = YES; 345 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 346 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 347 | COPY_PHASE_STRIP = NO; 348 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 349 | ENABLE_NS_ASSERTIONS = NO; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | GCC_C_LANGUAGE_STANDARD = gnu99; 352 | GCC_NO_COMMON_BLOCKS = YES; 353 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 354 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 355 | GCC_WARN_UNDECLARED_SELECTOR = YES; 356 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 357 | GCC_WARN_UNUSED_FUNCTION = YES; 358 | GCC_WARN_UNUSED_VARIABLE = YES; 359 | IPHONEOS_DEPLOYMENT_TARGET = 8.4; 360 | MTL_ENABLE_DEBUG_INFO = NO; 361 | SDKROOT = iphoneos; 362 | VALIDATE_PRODUCT = YES; 363 | }; 364 | name = Release; 365 | }; 366 | 9ABEDA281B7C7E3400C71B0B /* Debug */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 370 | INFOPLIST_FILE = "SDRecordButton-Demo/Info.plist"; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 372 | PRODUCT_BUNDLE_IDENTIFIER = "com.sebastiandobrincu.$(PRODUCT_NAME:rfc1034identifier)"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | }; 375 | name = Debug; 376 | }; 377 | 9ABEDA291B7C7E3400C71B0B /* Release */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 381 | INFOPLIST_FILE = "SDRecordButton-Demo/Info.plist"; 382 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 383 | PRODUCT_BUNDLE_IDENTIFIER = "com.sebastiandobrincu.$(PRODUCT_NAME:rfc1034identifier)"; 384 | PRODUCT_NAME = "$(TARGET_NAME)"; 385 | }; 386 | name = Release; 387 | }; 388 | 9ABEDA2B1B7C7E3400C71B0B /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | BUNDLE_LOADER = "$(TEST_HOST)"; 392 | FRAMEWORK_SEARCH_PATHS = ( 393 | "$(SDKROOT)/Developer/Library/Frameworks", 394 | "$(inherited)", 395 | ); 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | INFOPLIST_FILE = "SDRecordButton-DemoTests/Info.plist"; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = "com.sebastiandobrincu.$(PRODUCT_NAME:rfc1034identifier)"; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SDRecordButton-Demo.app/SDRecordButton-Demo"; 405 | }; 406 | name = Debug; 407 | }; 408 | 9ABEDA2C1B7C7E3400C71B0B /* Release */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | BUNDLE_LOADER = "$(TEST_HOST)"; 412 | FRAMEWORK_SEARCH_PATHS = ( 413 | "$(SDKROOT)/Developer/Library/Frameworks", 414 | "$(inherited)", 415 | ); 416 | INFOPLIST_FILE = "SDRecordButton-DemoTests/Info.plist"; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = "com.sebastiandobrincu.$(PRODUCT_NAME:rfc1034identifier)"; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SDRecordButton-Demo.app/SDRecordButton-Demo"; 421 | }; 422 | name = Release; 423 | }; 424 | /* End XCBuildConfiguration section */ 425 | 426 | /* Begin XCConfigurationList section */ 427 | 9ABED9FF1B7C7E3400C71B0B /* Build configuration list for PBXProject "SDRecordButton-Demo" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | 9ABEDA251B7C7E3400C71B0B /* Debug */, 431 | 9ABEDA261B7C7E3400C71B0B /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | 9ABEDA271B7C7E3400C71B0B /* Build configuration list for PBXNativeTarget "SDRecordButton-Demo" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | 9ABEDA281B7C7E3400C71B0B /* Debug */, 440 | 9ABEDA291B7C7E3400C71B0B /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | 9ABEDA2A1B7C7E3400C71B0B /* Build configuration list for PBXNativeTarget "SDRecordButton-DemoTests" */ = { 446 | isa = XCConfigurationList; 447 | buildConfigurations = ( 448 | 9ABEDA2B1B7C7E3400C71B0B /* Debug */, 449 | 9ABEDA2C1B7C7E3400C71B0B /* Release */, 450 | ); 451 | defaultConfigurationIsVisible = 0; 452 | defaultConfigurationName = Release; 453 | }; 454 | /* End XCConfigurationList section */ 455 | }; 456 | rootObject = 9ABED9FC1B7C7E3400C71B0B /* Project object */; 457 | } 458 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo.xcodeproj/project.xcworkspace/xcuserdata/Seby.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebyddd/SDRecordButton/f6575c4af8d5e3202c214fcbc125109f14ab14c0/SDRecordButton-Demo/SDRecordButton-Demo.xcodeproj/project.xcworkspace/xcuserdata/Seby.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo.xcodeproj/xcuserdata/Seby.xcuserdatad/xcschemes/SDRecordButton-Demo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo.xcodeproj/xcuserdata/Seby.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SDRecordButton-Demo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 9ABEDA031B7C7E3400C71B0B 16 | 17 | primary 18 | 19 | 20 | 9ABEDA1C1B7C7E3400C71B0B 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebyddd/SDRecordButton/f6575c4af8d5e3202c214fcbc125109f14ab14c0/SDRecordButton-Demo/SDRecordButton-Demo/.DS_Store -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SDRecordButton-Demo 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SDRecordButton-Demo 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application { 20 | // 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. 21 | // 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. 22 | } 23 | 24 | - (void)applicationDidEnterBackground:(UIApplication *)application { 25 | // 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. 26 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 27 | } 28 | 29 | - (void)applicationWillEnterForeground:(UIApplication *)application { 30 | // 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. 31 | } 32 | 33 | - (void)applicationDidBecomeActive:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationWillTerminate:(UIApplication *)application { 38 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/Base.lproj/Main.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 | 37 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/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 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/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 | UIStatusBarStyle 34 | UIStatusBarStyleLightContent 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UIViewControllerBasedStatusBarAppearance 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SDRecordButton-Demo 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SDRecordButton-Demo 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2017 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SDRecordButton.h" 11 | 12 | const int videoDuration = 5; 13 | 14 | @interface ViewController () 15 | @property (nonatomic, strong) IBOutlet SDRecordButton *recordButton; 16 | @property (nonatomic, strong) NSTimer *progressTimer; 17 | @property (nonatomic) CGFloat progress; 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | #pragma mark - SDRecordButton 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | [self randomColorTapped:nil]; 28 | } 29 | 30 | - (void)configureButtonWithColor:(UIColor*)color progressColor:(UIColor *)progressColor { 31 | 32 | // Configure colors 33 | self.recordButton.buttonColor = color; 34 | self.recordButton.progressColor = progressColor; 35 | 36 | // Add Targets 37 | [self.recordButton addTarget:self action:@selector(recording) forControlEvents:UIControlEventTouchDown]; 38 | [self.recordButton addTarget:self action:@selector(pausedRecording) forControlEvents:UIControlEventTouchUpInside]; 39 | [self.recordButton addTarget:self action:@selector(pausedRecording) forControlEvents:UIControlEventTouchUpOutside]; 40 | 41 | } 42 | 43 | - (void)recording { 44 | NSLog(@"Started recording"); 45 | self.progressTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateProgress) userInfo:nil repeats:YES]; 46 | } 47 | 48 | - (void)pausedRecording { 49 | NSLog(@"Paused recording"); 50 | [self.progressTimer invalidate]; 51 | } 52 | 53 | - (void)updateProgress { 54 | self.progress += 0.05/videoDuration; 55 | [self.recordButton setProgress:self.progress]; 56 | if (self.progress >= 1) 57 | [self.progressTimer invalidate]; 58 | } 59 | 60 | #pragma mark - User Interaction 61 | 62 | - (IBAction)resetProgressTapped:(id)sender { 63 | self.progress = 0; 64 | [self.recordButton setProgress:self.progress]; 65 | } 66 | 67 | - (IBAction)randomColorTapped:(id)sender { 68 | 69 | CGFloat hue1 = ( arc4random() % 256 / 256.0 ); 70 | CGFloat hue2 = ( arc4random() % 256 / 256.0 ); 71 | UIColor *buttonColor = [UIColor colorWithHue:hue1 saturation:0.95f brightness:0.89f alpha:1]; 72 | UIColor *progressColor = [UIColor colorWithHue:hue2 saturation:0.95f brightness:0.89f alpha:1]; 73 | 74 | SDRecordButton *btnCopy = [[SDRecordButton alloc] initWithFrame:CGRectMake(CGRectGetMidX(self.view.frame)-65/2, CGRectGetMidY(self.view.frame)-65/2, 65, 65)]; 75 | [self.recordButton removeFromSuperview]; 76 | self.recordButton = btnCopy; 77 | [self configureButtonWithColor:buttonColor progressColor:progressColor]; 78 | [self.view addSubview:self.recordButton]; 79 | 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-Demo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SDRecordButton-Demo 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-DemoTests/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 | -------------------------------------------------------------------------------- /SDRecordButton-Demo/SDRecordButton-DemoTests/SDRecordButton_DemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDRecordButton_DemoTests.m 3 | // SDRecordButton-DemoTests 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface SDRecordButton_DemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation SDRecordButton_DemoTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /SDRecordButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 4 | # 5 | # These will help people to find your library, and whilst it 6 | # can feel like a chore to fill in it's definitely to your advantage. The 7 | # summary should be tweet-length, and the description more in depth. 8 | # 9 | 10 | s.name = "SDRecordButton" 11 | s.version = "1.0.3" 12 | s.summary = "A handy UIButton subclass, meant to be used as a recording button." 13 | s.homepage = "https://github.com/sebyddd/SDRecordButton" 14 | s.screenshots = "https://dl.dropboxusercontent.com/s/9954jio68aqu5t6/sdrecordbutton2.png?dl=0" 15 | 16 | 17 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 18 | # 19 | # Licensing your code is important. See http://choosealicense.com for more info. 20 | # CocoaPods will detect a license file if there is a named LICENSE* 21 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 22 | # 23 | 24 | s.license = "MIT (example)" 25 | s.license = { :type => "MIT", :file => "LICENSE" } 26 | s.author = { "Sebastian Dobrincu" => "sebyddd@gmail.com" } 27 | s.platform = :ios 28 | s.ios.deployment_target = '7.0' 29 | s.source = { :git => 'https://github.com/sebyddd/SDRecordButton.git', :tag => "#{s.version}" } 30 | s.source_files = "SDRecordButton/*.{h,m}" 31 | 32 | s.requires_arc = true 33 | 34 | end -------------------------------------------------------------------------------- /SDRecordButton/SDRecordButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // SDRecordButton.h 3 | // SDRecordButton 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SDRecordButton : UIButton 12 | 13 | @property (nonatomic, strong) IBInspectable UIColor *buttonColor; 14 | @property (nonatomic, strong) IBInspectable UIColor *progressColor; 15 | @property (nonatomic, strong) CALayer *circleLayer; 16 | @property (nonatomic, strong) CALayer *circleBorder; 17 | @property (nonatomic, strong) CAShapeLayer *progressLayer; 18 | @property (nonatomic, strong) CAGradientLayer *gradientMaskLayer; 19 | 20 | - (void)setProgress:(CGFloat)newProgress; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /SDRecordButton/SDRecordButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDRecordButton.m 3 | // SDRecordButton 4 | // 5 | // Created by Sebastian Dobrincu on 13/08/15. 6 | // Copyright (c) 2015 Sebastian Dobrincu. All rights reserved. 7 | // 8 | 9 | #import "SDRecordButton.h" 10 | 11 | @interface SDRecordButton(){ 12 | UIColor *mainColor; 13 | UIColor *progColor; 14 | CGFloat currentProgress; 15 | } 16 | @end 17 | 18 | @implementation SDRecordButton 19 | 20 | - (id)initWithFrame:(CGRect)aRect { 21 | self = [super initWithFrame:aRect]; 22 | 23 | if (self) { 24 | [self addTarget:self action:@selector(didTouchDown) forControlEvents:UIControlEventTouchDown]; 25 | [self addTarget:self action:@selector(didTouchUp) forControlEvents:UIControlEventTouchUpInside]; 26 | [self addTarget:self action:@selector(didTouchUp) forControlEvents:UIControlEventTouchUpOutside]; 27 | [self drawButton]; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | - (id)initWithCoder:(NSCoder *)coder { 34 | self = [super initWithCoder:coder]; 35 | 36 | if (self) { 37 | [self addTarget:self action:@selector(didTouchDown) forControlEvents:UIControlEventTouchDown]; 38 | [self addTarget:self action:@selector(didTouchUp) forControlEvents:UIControlEventTouchUpInside]; 39 | [self addTarget:self action:@selector(didTouchUp) forControlEvents:UIControlEventTouchUpOutside]; 40 | [self drawButton]; 41 | } 42 | 43 | return self; 44 | } 45 | 46 | -(void)setProgressColor:(UIColor *)prColor { 47 | 48 | progColor = prColor; 49 | 50 | UIColor *topColor = progColor; 51 | UIColor *bottomColor = progColor; 52 | _gradientMaskLayer.colors = @[(id)topColor.CGColor, (id)bottomColor.CGColor]; 53 | 54 | } 55 | 56 | -(void)setButtonColor:(UIColor *)buttonColor{ 57 | 58 | _circleLayer.backgroundColor = buttonColor.CGColor; 59 | _circleBorder.borderColor = buttonColor.CGColor; 60 | 61 | mainColor = buttonColor; 62 | } 63 | 64 | - (void)drawButton { 65 | 66 | currentProgress = 0; 67 | self.backgroundColor = [UIColor clearColor]; 68 | 69 | // Get the root layer 70 | CALayer *layer = self.layer; 71 | 72 | if (!_circleLayer) { 73 | 74 | _circleLayer = [CALayer layer]; 75 | _circleLayer.backgroundColor = mainColor.CGColor; 76 | 77 | CGFloat size = self.frame.size.width/1.5; 78 | _circleLayer.bounds = CGRectMake(0, 0, size, size); 79 | _circleLayer.anchorPoint = CGPointMake(0.5, 0.5); 80 | _circleLayer.position = (CGPoint){CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)}; 81 | 82 | _circleLayer.cornerRadius = size/2; 83 | 84 | [layer insertSublayer:_circleLayer atIndex:0]; 85 | } 86 | 87 | if (!_circleBorder) { 88 | 89 | _circleBorder = [CALayer layer]; 90 | _circleBorder.backgroundColor = [UIColor clearColor].CGColor; 91 | _circleBorder.borderWidth = 1; 92 | _circleBorder.borderColor = mainColor.CGColor; 93 | 94 | _circleBorder.bounds = CGRectMake(0, 0, self.bounds.size.width-1.5f, self.bounds.size.height-1.5f); 95 | _circleBorder.anchorPoint = CGPointMake(0.5, 0.5); 96 | _circleBorder.position = (CGPoint){CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)}; 97 | 98 | _circleBorder.cornerRadius = self.frame.size.width/2; 99 | 100 | [layer insertSublayer:_circleBorder atIndex:0]; 101 | } 102 | 103 | if (!_progressLayer) { 104 | 105 | CGFloat startAngle = M_PI + M_PI_2; 106 | CGFloat endAngle = M_PI * 3 + M_PI_2; 107 | CGPoint centerPoint = CGPointMake(self.frame.size.width/2, self.frame.size.height/2); 108 | 109 | _gradientMaskLayer = [self gradientMask]; 110 | _progressLayer = [CAShapeLayer layer]; 111 | _progressLayer.path = [UIBezierPath bezierPathWithArcCenter:centerPoint radius:self.frame.size.width/2-2 startAngle:startAngle endAngle:endAngle clockwise:YES].CGPath; 112 | _progressLayer.backgroundColor = [UIColor clearColor].CGColor; 113 | _progressLayer.fillColor = nil; 114 | _progressLayer.strokeColor = [UIColor blackColor].CGColor; 115 | _progressLayer.lineWidth = 4.0; 116 | _progressLayer.strokeStart = 0.0; 117 | _progressLayer.strokeEnd = 0.0; 118 | 119 | _gradientMaskLayer.mask = _progressLayer; 120 | [layer insertSublayer:_gradientMaskLayer atIndex:0]; 121 | } 122 | } 123 | 124 | - (CAGradientLayer *)gradientMask { 125 | 126 | CAGradientLayer *gradientLayer = [CAGradientLayer layer]; 127 | gradientLayer.frame = self.bounds; 128 | gradientLayer.locations = @[@0.0, @1.0]; 129 | 130 | if (!progColor) 131 | progColor = [UIColor blueColor]; 132 | 133 | UIColor *topColor = progColor; 134 | UIColor *bottomColor = progColor; 135 | 136 | gradientLayer.colors = @[(id)topColor.CGColor, (id)bottomColor.CGColor]; 137 | 138 | return gradientLayer; 139 | } 140 | 141 | 142 | - (void)layoutSubviews { 143 | 144 | _circleLayer.anchorPoint = CGPointMake(0.5, 0.5); 145 | _circleLayer.position = (CGPoint){CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)}; 146 | 147 | _circleBorder.anchorPoint = CGPointMake(0.5, 0.5); 148 | _circleBorder.position = (CGPoint){CGRectGetMidX(self.bounds), CGRectGetMidY(self.bounds)}; 149 | 150 | [super layoutSubviews]; 151 | } 152 | 153 | - (void)didTouchDown { 154 | 155 | CGFloat duration = 0.15; 156 | _circleLayer.contentsGravity = @"center"; 157 | 158 | // Animate main circle 159 | CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 160 | scale.fromValue = @1.0; 161 | scale.toValue = @0.88; 162 | [scale setDuration:duration]; 163 | scale.fillMode = kCAFillModeForwards; 164 | scale.removedOnCompletion = NO; 165 | CABasicAnimation *color = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; 166 | [color setDuration:duration]; 167 | color.fillMode = kCAFillModeForwards; 168 | color.removedOnCompletion = NO; 169 | color.toValue = (id)progColor.CGColor; 170 | 171 | CAAnimationGroup *circleAnimations = [CAAnimationGroup animation]; 172 | circleAnimations.removedOnCompletion = NO; 173 | circleAnimations.fillMode = kCAFillModeForwards; 174 | [circleAnimations setDuration:duration]; 175 | [circleAnimations setAnimations:@[scale, color]]; 176 | 177 | // Animate border 178 | CABasicAnimation *borderColor = [CABasicAnimation animationWithKeyPath:@"borderColor"]; 179 | borderColor.duration = duration; 180 | borderColor.fillMode = kCAFillModeForwards; 181 | borderColor.removedOnCompletion = NO; 182 | borderColor.toValue = (id)[UIColor colorWithRed:0.83 green:0.86 blue:0.89 alpha:1].CGColor; 183 | CABasicAnimation *borderScale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 184 | borderScale.fromValue = [NSNumber numberWithFloat:[[_circleBorder.presentationLayer valueForKeyPath: @"transform.scale"] floatValue]]; 185 | borderScale.toValue = @0.88; 186 | [borderScale setDuration:duration]; 187 | borderScale.fillMode = kCAFillModeForwards; 188 | borderScale.removedOnCompletion = NO; 189 | 190 | CAAnimationGroup *borderAnimations = [CAAnimationGroup animation]; 191 | borderAnimations.removedOnCompletion = NO; 192 | borderAnimations.fillMode = kCAFillModeForwards; 193 | [borderAnimations setDuration:duration]; 194 | [borderAnimations setAnimations:@[borderColor, borderScale]]; 195 | 196 | // Animate progress 197 | CABasicAnimation *fadeIn = [CABasicAnimation animationWithKeyPath:@"opacity"]; 198 | fadeIn.fromValue = @0.0; 199 | fadeIn.toValue = @1.0; 200 | fadeIn.duration = duration; 201 | fadeIn.fillMode = kCAFillModeForwards; 202 | fadeIn.removedOnCompletion = NO; 203 | 204 | [_progressLayer addAnimation:fadeIn forKey:@"fadeIn"]; 205 | [_circleBorder addAnimation:borderAnimations forKey:@"borderAnimations"]; 206 | [_circleLayer addAnimation:circleAnimations forKey:@"circleAnimations"]; 207 | } 208 | 209 | 210 | - (void)didTouchUp { 211 | 212 | CGFloat duration = 0.15; 213 | 214 | CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 215 | scale.fromValue = @0.88; 216 | scale.toValue = @1.0; 217 | [scale setDuration:duration]; 218 | scale.fillMode = kCAFillModeForwards; 219 | scale.removedOnCompletion = NO; 220 | CABasicAnimation *color = [CABasicAnimation animationWithKeyPath:@"backgroundColor"]; 221 | color.fillMode = kCAFillModeForwards; 222 | color.removedOnCompletion = NO; 223 | color.toValue = (id)mainColor.CGColor; 224 | 225 | CAAnimationGroup *animations = [CAAnimationGroup animation]; 226 | animations.removedOnCompletion = NO; 227 | animations.fillMode = kCAFillModeForwards; 228 | [animations setDuration:duration] ; 229 | [animations setAnimations:@[scale, color]]; 230 | 231 | CABasicAnimation *borderColor = [CABasicAnimation animationWithKeyPath:@"borderColor"]; 232 | borderColor.duration = duration; 233 | borderColor.fillMode = kCAFillModeForwards; 234 | borderColor.removedOnCompletion = NO; 235 | borderColor.toValue = (id)mainColor.CGColor; 236 | CABasicAnimation *borderScale = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; 237 | borderScale.fromValue = @0.88; 238 | borderScale.toValue = @1.0; 239 | [borderScale setDuration:duration]; 240 | borderScale.fillMode = kCAFillModeForwards; 241 | borderScale.removedOnCompletion = NO; 242 | 243 | CAAnimationGroup *borderAnimations = [CAAnimationGroup animation]; 244 | borderAnimations.removedOnCompletion = NO; 245 | borderAnimations.fillMode = kCAFillModeForwards; 246 | [borderAnimations setDuration:duration]; 247 | [borderAnimations setAnimations:@[borderColor, borderScale]]; 248 | 249 | 250 | // Animate progress 251 | CABasicAnimation *fadeOut = [CABasicAnimation animationWithKeyPath:@"opacity"]; 252 | fadeOut.fromValue = @1.0; 253 | fadeOut.toValue = @0.0; 254 | fadeOut.duration = duration*2; 255 | fadeOut.fillMode = kCAFillModeForwards; 256 | fadeOut.removedOnCompletion = NO; 257 | 258 | [_progressLayer addAnimation:fadeOut forKey:@"fadeOut"]; 259 | [_circleBorder addAnimation:borderAnimations forKey:@"borderAnimations"]; 260 | [_circleLayer addAnimation:animations forKey:@"circleAnimations"]; 261 | } 262 | 263 | - (void)setProgress:(CGFloat)newProgress{ 264 | _progressLayer.strokeEnd = newProgress; 265 | 266 | } 267 | 268 | @end 269 | --------------------------------------------------------------------------------