├── .gitignore ├── AnimateButton.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── AnimateButton ├── AnimateButton-Info.plist ├── AnimateButton-Prefix.pch ├── AppDelegate.h ├── AppDelegate.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── image.imageset │ │ ├── Contents.json │ │ └── image@2x.png │ └── pic.imageset │ │ ├── Contents.json │ │ └── pic@2x.png ├── Vendors │ ├── UIImage+ImageEffects.h │ ├── UIImage+ImageEffects.m │ ├── UIImageView+LBBlurredImage.h │ └── UIImageView+LBBlurredImage.m ├── ViewController.h ├── ViewController.m ├── en.lproj │ └── InfoPlist.strings ├── main.m └── twitter@2x.png ├── AnimateButtonTests ├── AnimateButtonTests-Info.plist ├── AnimateButtonTests.m └── en.lproj │ └── InfoPlist.strings ├── LICENSE ├── MRoundedButton.h ├── MRoundedButton.m ├── MRoundedButton.podspec ├── README.md ├── present.PNG └── present.gif /.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/ -------------------------------------------------------------------------------- /AnimateButton.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C113692118C3441100034926 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C113692018C3441100034926 /* Foundation.framework */; }; 11 | C113692318C3441100034926 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C113692218C3441100034926 /* CoreGraphics.framework */; }; 12 | C113692518C3441100034926 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C113692418C3441100034926 /* UIKit.framework */; }; 13 | C113692B18C3441100034926 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C113692918C3441100034926 /* InfoPlist.strings */; }; 14 | C113692D18C3441100034926 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C113692C18C3441100034926 /* main.m */; }; 15 | C113693118C3441100034926 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C113693018C3441100034926 /* AppDelegate.m */; }; 16 | C113693718C3441100034926 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C113693618C3441100034926 /* ViewController.m */; }; 17 | C113693918C3441100034926 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C113693818C3441100034926 /* Images.xcassets */; }; 18 | C113694018C3441100034926 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C113693F18C3441100034926 /* XCTest.framework */; }; 19 | C113694118C3441100034926 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C113692018C3441100034926 /* Foundation.framework */; }; 20 | C113694218C3441100034926 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C113692418C3441100034926 /* UIKit.framework */; }; 21 | C113694A18C3441100034926 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = C113694818C3441100034926 /* InfoPlist.strings */; }; 22 | C113694C18C3441100034926 /* AnimateButtonTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C113694B18C3441100034926 /* AnimateButtonTests.m */; }; 23 | C11DB9CA193389D40028F7D3 /* present.gif in Resources */ = {isa = PBXBuildFile; fileRef = C11DB9C9193389D40028F7D3 /* present.gif */; }; 24 | C168242018E27D2A00BDC643 /* twitter@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C168241F18E27D2A00BDC643 /* twitter@2x.png */; }; 25 | C1E42809192A037E0086BC61 /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = C1E42806192A037E0086BC61 /* UIImage+ImageEffects.m */; }; 26 | C1E4280A192A037E0086BC61 /* UIImageView+LBBlurredImage.m in Sources */ = {isa = PBXBuildFile; fileRef = C1E42808192A037E0086BC61 /* UIImageView+LBBlurredImage.m */; }; 27 | C1E42814192A08150086BC61 /* present.PNG in Resources */ = {isa = PBXBuildFile; fileRef = C1E42813192A08150086BC61 /* present.PNG */; }; 28 | C1E42817192A55B80086BC61 /* MRoundedButton.m in Sources */ = {isa = PBXBuildFile; fileRef = C1E42816192A55B80086BC61 /* MRoundedButton.m */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | C113694318C3441100034926 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = C113691518C3441100034926 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = C113691C18C3441100034926; 37 | remoteInfo = AnimateButton; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | C113691D18C3441100034926 /* AnimateButton.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnimateButton.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | C113692018C3441100034926 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 44 | C113692218C3441100034926 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 45 | C113692418C3441100034926 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 46 | C113692818C3441100034926 /* AnimateButton-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AnimateButton-Info.plist"; sourceTree = ""; }; 47 | C113692A18C3441100034926 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 48 | C113692C18C3441100034926 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 49 | C113692E18C3441100034926 /* AnimateButton-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AnimateButton-Prefix.pch"; sourceTree = ""; }; 50 | C113692F18C3441100034926 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 51 | C113693018C3441100034926 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 52 | C113693518C3441100034926 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 53 | C113693618C3441100034926 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 54 | C113693818C3441100034926 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 55 | C113693E18C3441100034926 /* AnimateButtonTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AnimateButtonTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 56 | C113693F18C3441100034926 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 57 | C113694718C3441100034926 /* AnimateButtonTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AnimateButtonTests-Info.plist"; sourceTree = ""; }; 58 | C113694918C3441100034926 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 59 | C113694B18C3441100034926 /* AnimateButtonTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnimateButtonTests.m; sourceTree = ""; }; 60 | C11DB9C9193389D40028F7D3 /* present.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = present.gif; sourceTree = SOURCE_ROOT; }; 61 | C168241F18E27D2A00BDC643 /* twitter@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter@2x.png"; sourceTree = ""; }; 62 | C1E42805192A037E0086BC61 /* UIImage+ImageEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+ImageEffects.h"; sourceTree = ""; }; 63 | C1E42806192A037E0086BC61 /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ImageEffects.m"; sourceTree = ""; }; 64 | C1E42807192A037E0086BC61 /* UIImageView+LBBlurredImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+LBBlurredImage.h"; sourceTree = ""; }; 65 | C1E42808192A037E0086BC61 /* UIImageView+LBBlurredImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+LBBlurredImage.m"; sourceTree = ""; }; 66 | C1E42813192A08150086BC61 /* present.PNG */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = present.PNG; sourceTree = SOURCE_ROOT; }; 67 | C1E42815192A55B80086BC61 /* MRoundedButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRoundedButton.h; sourceTree = SOURCE_ROOT; }; 68 | C1E42816192A55B80086BC61 /* MRoundedButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRoundedButton.m; sourceTree = SOURCE_ROOT; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | C113691A18C3441100034926 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | C113692318C3441100034926 /* CoreGraphics.framework in Frameworks */, 77 | C113692518C3441100034926 /* UIKit.framework in Frameworks */, 78 | C113692118C3441100034926 /* Foundation.framework in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | C113693B18C3441100034926 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | C113694018C3441100034926 /* XCTest.framework in Frameworks */, 87 | C113694218C3441100034926 /* UIKit.framework in Frameworks */, 88 | C113694118C3441100034926 /* Foundation.framework in Frameworks */, 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | C113691418C3441100034926 = { 96 | isa = PBXGroup; 97 | children = ( 98 | C113692618C3441100034926 /* AnimateButton */, 99 | C113694518C3441100034926 /* AnimateButtonTests */, 100 | C113691F18C3441100034926 /* Frameworks */, 101 | C113691E18C3441100034926 /* Products */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | C113691E18C3441100034926 /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | C113691D18C3441100034926 /* AnimateButton.app */, 109 | C113693E18C3441100034926 /* AnimateButtonTests.xctest */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | C113691F18C3441100034926 /* Frameworks */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | C113692018C3441100034926 /* Foundation.framework */, 118 | C113692218C3441100034926 /* CoreGraphics.framework */, 119 | C113692418C3441100034926 /* UIKit.framework */, 120 | C113693F18C3441100034926 /* XCTest.framework */, 121 | ); 122 | name = Frameworks; 123 | sourceTree = ""; 124 | }; 125 | C113692618C3441100034926 /* AnimateButton */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | C1E42815192A55B80086BC61 /* MRoundedButton.h */, 129 | C1E42816192A55B80086BC61 /* MRoundedButton.m */, 130 | C1E42804192A037E0086BC61 /* Vendors */, 131 | C113692F18C3441100034926 /* AppDelegate.h */, 132 | C113693018C3441100034926 /* AppDelegate.m */, 133 | C113693518C3441100034926 /* ViewController.h */, 134 | C113693618C3441100034926 /* ViewController.m */, 135 | C113693818C3441100034926 /* Images.xcassets */, 136 | C113692718C3441100034926 /* Supporting Files */, 137 | ); 138 | path = AnimateButton; 139 | sourceTree = ""; 140 | }; 141 | C113692718C3441100034926 /* Supporting Files */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | C11DB9C9193389D40028F7D3 /* present.gif */, 145 | C1E42813192A08150086BC61 /* present.PNG */, 146 | C168241F18E27D2A00BDC643 /* twitter@2x.png */, 147 | C113692818C3441100034926 /* AnimateButton-Info.plist */, 148 | C113692918C3441100034926 /* InfoPlist.strings */, 149 | C113692C18C3441100034926 /* main.m */, 150 | C113692E18C3441100034926 /* AnimateButton-Prefix.pch */, 151 | ); 152 | name = "Supporting Files"; 153 | sourceTree = ""; 154 | }; 155 | C113694518C3441100034926 /* AnimateButtonTests */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | C113694B18C3441100034926 /* AnimateButtonTests.m */, 159 | C113694618C3441100034926 /* Supporting Files */, 160 | ); 161 | path = AnimateButtonTests; 162 | sourceTree = ""; 163 | }; 164 | C113694618C3441100034926 /* Supporting Files */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | C113694718C3441100034926 /* AnimateButtonTests-Info.plist */, 168 | C113694818C3441100034926 /* InfoPlist.strings */, 169 | ); 170 | name = "Supporting Files"; 171 | sourceTree = ""; 172 | }; 173 | C1E42804192A037E0086BC61 /* Vendors */ = { 174 | isa = PBXGroup; 175 | children = ( 176 | C1E42805192A037E0086BC61 /* UIImage+ImageEffects.h */, 177 | C1E42806192A037E0086BC61 /* UIImage+ImageEffects.m */, 178 | C1E42807192A037E0086BC61 /* UIImageView+LBBlurredImage.h */, 179 | C1E42808192A037E0086BC61 /* UIImageView+LBBlurredImage.m */, 180 | ); 181 | path = Vendors; 182 | sourceTree = ""; 183 | }; 184 | /* End PBXGroup section */ 185 | 186 | /* Begin PBXNativeTarget section */ 187 | C113691C18C3441100034926 /* AnimateButton */ = { 188 | isa = PBXNativeTarget; 189 | buildConfigurationList = C113694F18C3441100034926 /* Build configuration list for PBXNativeTarget "AnimateButton" */; 190 | buildPhases = ( 191 | C113691918C3441100034926 /* Sources */, 192 | C113691A18C3441100034926 /* Frameworks */, 193 | C113691B18C3441100034926 /* Resources */, 194 | C13A4CFD18D00FC000EBE3D9 /* ShellScript */, 195 | ); 196 | buildRules = ( 197 | ); 198 | dependencies = ( 199 | ); 200 | name = AnimateButton; 201 | productName = AnimateButton; 202 | productReference = C113691D18C3441100034926 /* AnimateButton.app */; 203 | productType = "com.apple.product-type.application"; 204 | }; 205 | C113693D18C3441100034926 /* AnimateButtonTests */ = { 206 | isa = PBXNativeTarget; 207 | buildConfigurationList = C113695218C3441100034926 /* Build configuration list for PBXNativeTarget "AnimateButtonTests" */; 208 | buildPhases = ( 209 | C113693A18C3441100034926 /* Sources */, 210 | C113693B18C3441100034926 /* Frameworks */, 211 | C113693C18C3441100034926 /* Resources */, 212 | ); 213 | buildRules = ( 214 | ); 215 | dependencies = ( 216 | C113694418C3441100034926 /* PBXTargetDependency */, 217 | ); 218 | name = AnimateButtonTests; 219 | productName = AnimateButtonTests; 220 | productReference = C113693E18C3441100034926 /* AnimateButtonTests.xctest */; 221 | productType = "com.apple.product-type.bundle.unit-test"; 222 | }; 223 | /* End PBXNativeTarget section */ 224 | 225 | /* Begin PBXProject section */ 226 | C113691518C3441100034926 /* Project object */ = { 227 | isa = PBXProject; 228 | attributes = { 229 | LastUpgradeCheck = 0500; 230 | ORGANIZATIONNAME = "Michael WU"; 231 | TargetAttributes = { 232 | C113693D18C3441100034926 = { 233 | TestTargetID = C113691C18C3441100034926; 234 | }; 235 | }; 236 | }; 237 | buildConfigurationList = C113691818C3441100034926 /* Build configuration list for PBXProject "AnimateButton" */; 238 | compatibilityVersion = "Xcode 3.2"; 239 | developmentRegion = English; 240 | hasScannedForEncodings = 0; 241 | knownRegions = ( 242 | en, 243 | Base, 244 | ); 245 | mainGroup = C113691418C3441100034926; 246 | productRefGroup = C113691E18C3441100034926 /* Products */; 247 | projectDirPath = ""; 248 | projectRoot = ""; 249 | targets = ( 250 | C113691C18C3441100034926 /* AnimateButton */, 251 | C113693D18C3441100034926 /* AnimateButtonTests */, 252 | ); 253 | }; 254 | /* End PBXProject section */ 255 | 256 | /* Begin PBXResourcesBuildPhase section */ 257 | C113691B18C3441100034926 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | C113693918C3441100034926 /* Images.xcassets in Resources */, 262 | C113692B18C3441100034926 /* InfoPlist.strings in Resources */, 263 | C168242018E27D2A00BDC643 /* twitter@2x.png in Resources */, 264 | C11DB9CA193389D40028F7D3 /* present.gif in Resources */, 265 | C1E42814192A08150086BC61 /* present.PNG in Resources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | C113693C18C3441100034926 /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | C113694A18C3441100034926 /* InfoPlist.strings in Resources */, 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | /* End PBXResourcesBuildPhase section */ 278 | 279 | /* Begin PBXShellScriptBuildPhase section */ 280 | C13A4CFD18D00FC000EBE3D9 /* ShellScript */ = { 281 | isa = PBXShellScriptBuildPhase; 282 | buildActionMask = 2147483647; 283 | files = ( 284 | ); 285 | inputPaths = ( 286 | ); 287 | outputPaths = ( 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | shellPath = /bin/sh; 291 | shellScript = ""; 292 | }; 293 | /* End PBXShellScriptBuildPhase section */ 294 | 295 | /* Begin PBXSourcesBuildPhase section */ 296 | C113691918C3441100034926 /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | C1E42809192A037E0086BC61 /* UIImage+ImageEffects.m in Sources */, 301 | C1E42817192A55B80086BC61 /* MRoundedButton.m in Sources */, 302 | C113693718C3441100034926 /* ViewController.m in Sources */, 303 | C1E4280A192A037E0086BC61 /* UIImageView+LBBlurredImage.m in Sources */, 304 | C113693118C3441100034926 /* AppDelegate.m in Sources */, 305 | C113692D18C3441100034926 /* main.m in Sources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | C113693A18C3441100034926 /* Sources */ = { 310 | isa = PBXSourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | C113694C18C3441100034926 /* AnimateButtonTests.m in Sources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | /* End PBXSourcesBuildPhase section */ 318 | 319 | /* Begin PBXTargetDependency section */ 320 | C113694418C3441100034926 /* PBXTargetDependency */ = { 321 | isa = PBXTargetDependency; 322 | target = C113691C18C3441100034926 /* AnimateButton */; 323 | targetProxy = C113694318C3441100034926 /* PBXContainerItemProxy */; 324 | }; 325 | /* End PBXTargetDependency section */ 326 | 327 | /* Begin PBXVariantGroup section */ 328 | C113692918C3441100034926 /* InfoPlist.strings */ = { 329 | isa = PBXVariantGroup; 330 | children = ( 331 | C113692A18C3441100034926 /* en */, 332 | ); 333 | name = InfoPlist.strings; 334 | sourceTree = ""; 335 | }; 336 | C113694818C3441100034926 /* InfoPlist.strings */ = { 337 | isa = PBXVariantGroup; 338 | children = ( 339 | C113694918C3441100034926 /* en */, 340 | ); 341 | name = InfoPlist.strings; 342 | sourceTree = ""; 343 | }; 344 | /* End PBXVariantGroup section */ 345 | 346 | /* Begin XCBuildConfiguration section */ 347 | C113694D18C3441100034926 /* Debug */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | ALWAYS_SEARCH_USER_PATHS = NO; 351 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 359 | CLANG_WARN_EMPTY_BODY = YES; 360 | CLANG_WARN_ENUM_CONVERSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 364 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 365 | COPY_PHASE_STRIP = NO; 366 | GCC_C_LANGUAGE_STANDARD = gnu99; 367 | GCC_DYNAMIC_NO_PIC = NO; 368 | GCC_OPTIMIZATION_LEVEL = 0; 369 | GCC_PREPROCESSOR_DEFINITIONS = ( 370 | "DEBUG=1", 371 | "$(inherited)", 372 | ); 373 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 374 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 375 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 376 | GCC_WARN_UNDECLARED_SELECTOR = YES; 377 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 378 | GCC_WARN_UNUSED_FUNCTION = YES; 379 | GCC_WARN_UNUSED_VARIABLE = YES; 380 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 381 | ONLY_ACTIVE_ARCH = YES; 382 | SDKROOT = iphoneos; 383 | }; 384 | name = Debug; 385 | }; 386 | C113694E18C3441100034926 /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ALWAYS_SEARCH_USER_PATHS = NO; 390 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 391 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 392 | CLANG_CXX_LIBRARY = "libc++"; 393 | CLANG_ENABLE_MODULES = YES; 394 | CLANG_ENABLE_OBJC_ARC = YES; 395 | CLANG_WARN_BOOL_CONVERSION = YES; 396 | CLANG_WARN_CONSTANT_CONVERSION = YES; 397 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 398 | CLANG_WARN_EMPTY_BODY = YES; 399 | CLANG_WARN_ENUM_CONVERSION = YES; 400 | CLANG_WARN_INT_CONVERSION = YES; 401 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 402 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 403 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 404 | COPY_PHASE_STRIP = YES; 405 | ENABLE_NS_ASSERTIONS = NO; 406 | GCC_C_LANGUAGE_STANDARD = gnu99; 407 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 408 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 409 | GCC_WARN_UNDECLARED_SELECTOR = YES; 410 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 411 | GCC_WARN_UNUSED_FUNCTION = YES; 412 | GCC_WARN_UNUSED_VARIABLE = YES; 413 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 414 | SDKROOT = iphoneos; 415 | VALIDATE_PRODUCT = YES; 416 | }; 417 | name = Release; 418 | }; 419 | C113695018C3441100034926 /* Debug */ = { 420 | isa = XCBuildConfiguration; 421 | buildSettings = { 422 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 423 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 424 | FRAMEWORK_SEARCH_PATHS = "$(inherited)"; 425 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 426 | GCC_PREFIX_HEADER = "AnimateButton/AnimateButton-Prefix.pch"; 427 | INFOPLIST_FILE = "AnimateButton/AnimateButton-Info.plist"; 428 | PRODUCT_NAME = "$(TARGET_NAME)"; 429 | WRAPPER_EXTENSION = app; 430 | }; 431 | name = Debug; 432 | }; 433 | C113695118C3441100034926 /* Release */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 437 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 438 | FRAMEWORK_SEARCH_PATHS = "$(inherited)"; 439 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 440 | GCC_PREFIX_HEADER = "AnimateButton/AnimateButton-Prefix.pch"; 441 | INFOPLIST_FILE = "AnimateButton/AnimateButton-Info.plist"; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | WRAPPER_EXTENSION = app; 444 | }; 445 | name = Release; 446 | }; 447 | C113695318C3441100034926 /* Debug */ = { 448 | isa = XCBuildConfiguration; 449 | buildSettings = { 450 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 451 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AnimateButton.app/AnimateButton"; 452 | FRAMEWORK_SEARCH_PATHS = ( 453 | "$(SDKROOT)/Developer/Library/Frameworks", 454 | "$(inherited)", 455 | "$(DEVELOPER_FRAMEWORKS_DIR)", 456 | ); 457 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 458 | GCC_PREFIX_HEADER = "AnimateButton/AnimateButton-Prefix.pch"; 459 | GCC_PREPROCESSOR_DEFINITIONS = ( 460 | "DEBUG=1", 461 | "$(inherited)", 462 | ); 463 | INFOPLIST_FILE = "AnimateButtonTests/AnimateButtonTests-Info.plist"; 464 | PRODUCT_NAME = "$(TARGET_NAME)"; 465 | TEST_HOST = "$(BUNDLE_LOADER)"; 466 | WRAPPER_EXTENSION = xctest; 467 | }; 468 | name = Debug; 469 | }; 470 | C113695418C3441100034926 /* Release */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 474 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/AnimateButton.app/AnimateButton"; 475 | FRAMEWORK_SEARCH_PATHS = ( 476 | "$(SDKROOT)/Developer/Library/Frameworks", 477 | "$(inherited)", 478 | "$(DEVELOPER_FRAMEWORKS_DIR)", 479 | ); 480 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 481 | GCC_PREFIX_HEADER = "AnimateButton/AnimateButton-Prefix.pch"; 482 | INFOPLIST_FILE = "AnimateButtonTests/AnimateButtonTests-Info.plist"; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | TEST_HOST = "$(BUNDLE_LOADER)"; 485 | WRAPPER_EXTENSION = xctest; 486 | }; 487 | name = Release; 488 | }; 489 | /* End XCBuildConfiguration section */ 490 | 491 | /* Begin XCConfigurationList section */ 492 | C113691818C3441100034926 /* Build configuration list for PBXProject "AnimateButton" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | C113694D18C3441100034926 /* Debug */, 496 | C113694E18C3441100034926 /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | C113694F18C3441100034926 /* Build configuration list for PBXNativeTarget "AnimateButton" */ = { 502 | isa = XCConfigurationList; 503 | buildConfigurations = ( 504 | C113695018C3441100034926 /* Debug */, 505 | C113695118C3441100034926 /* Release */, 506 | ); 507 | defaultConfigurationIsVisible = 0; 508 | defaultConfigurationName = Release; 509 | }; 510 | C113695218C3441100034926 /* Build configuration list for PBXNativeTarget "AnimateButtonTests" */ = { 511 | isa = XCConfigurationList; 512 | buildConfigurations = ( 513 | C113695318C3441100034926 /* Debug */, 514 | C113695418C3441100034926 /* Release */, 515 | ); 516 | defaultConfigurationIsVisible = 0; 517 | defaultConfigurationName = Release; 518 | }; 519 | /* End XCConfigurationList section */ 520 | }; 521 | rootObject = C113691518C3441100034926 /* Project object */; 522 | } 523 | -------------------------------------------------------------------------------- /AnimateButton.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AnimateButton/AnimateButton-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.michaelwu.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewEdgeAntialiasing 38 | 39 | UIViewGroupOpacity 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /AnimateButton/AnimateButton-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /AnimateButton/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AnimateButton 4 | // 5 | // Copyright (c) 2014 Michael WU. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import 26 | 27 | @interface AppDelegate : UIResponder 28 | 29 | @property (strong, nonatomic) UIWindow *window; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /AnimateButton/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AnimateButton 4 | // 5 | // Copyright (c) 2014 Michael WU. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import "AppDelegate.h" 26 | #import "ViewController.h" 27 | #import "MRoundedButton.h" 28 | 29 | @implementation AppDelegate 30 | 31 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 32 | { 33 | // Override point for customization after application launch. 34 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 35 | self.window.backgroundColor = [UIColor whiteColor]; 36 | 37 | 38 | NSDictionary *appearanceProxy1 = @{kMRoundedButtonCornerRadius : @40, 39 | kMRoundedButtonBorderWidth : @2, 40 | kMRoundedButtonBorderColor : [UIColor clearColor], 41 | kMRoundedButtonContentColor : [UIColor blackColor], 42 | kMRoundedButtonContentAnimateToColor : [UIColor whiteColor], 43 | kMRoundedButtonForegroundColor : [UIColor whiteColor], 44 | kMRoundedButtonForegroundAnimateToColor : [UIColor clearColor]}; 45 | NSDictionary *appearanceProxy2 = @{kMRoundedButtonCornerRadius : @25, 46 | kMRoundedButtonBorderWidth : @1.5, 47 | kMRoundedButtonRestoreSelectedState : @NO, 48 | kMRoundedButtonBorderColor : [[UIColor blackColor] colorWithAlphaComponent:0.5], 49 | kMRoundedButtonBorderAnimateToColor : [UIColor whiteColor], 50 | kMRoundedButtonContentColor : [[UIColor blackColor] colorWithAlphaComponent:0.5], 51 | kMRoundedButtonContentAnimateToColor : [UIColor whiteColor], 52 | kMRoundedButtonForegroundColor : [[UIColor whiteColor] colorWithAlphaComponent:0.5]}; 53 | NSDictionary *appearanceProxy3 = @{kMRoundedButtonCornerRadius : @40, 54 | kMRoundedButtonBorderWidth : @2, 55 | kMRoundedButtonRestoreSelectedState : @NO, 56 | kMRoundedButtonBorderColor : [UIColor clearColor], 57 | kMRoundedButtonBorderAnimateToColor : [UIColor whiteColor], 58 | kMRoundedButtonContentColor : [UIColor whiteColor], 59 | kMRoundedButtonContentAnimateToColor : [UIColor blackColor], 60 | kMRoundedButtonForegroundColor : [[UIColor blackColor] colorWithAlphaComponent:0.5], 61 | kMRoundedButtonForegroundAnimateToColor : [UIColor whiteColor]}; 62 | 63 | [MRoundedButtonAppearanceManager registerAppearanceProxy:appearanceProxy1 forIdentifier:@"1"]; 64 | [MRoundedButtonAppearanceManager registerAppearanceProxy:appearanceProxy2 forIdentifier:@"2"]; 65 | [MRoundedButtonAppearanceManager registerAppearanceProxy:appearanceProxy3 forIdentifier:@"3"]; 66 | 67 | ViewController *controller = [[ViewController alloc] initWithNibName:nil bundle:nil]; 68 | self.window.rootViewController = controller; 69 | [self.window makeKeyAndVisible]; 70 | 71 | return YES; 72 | } 73 | 74 | - (void)applicationWillResignActive:(UIApplication *)application 75 | { 76 | // 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. 77 | // 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. 78 | } 79 | 80 | - (void)applicationDidEnterBackground:(UIApplication *)application 81 | { 82 | // 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. 83 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 84 | } 85 | 86 | - (void)applicationWillEnterForeground:(UIApplication *)application 87 | { 88 | // 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. 89 | } 90 | 91 | - (void)applicationDidBecomeActive:(UIApplication *)application 92 | { 93 | // 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. 94 | } 95 | 96 | - (void)applicationWillTerminate:(UIApplication *)application 97 | { 98 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /AnimateButton/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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /AnimateButton/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /AnimateButton/Images.xcassets/image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "image@2x.png" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /AnimateButton/Images.xcassets/image.imageset/image@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcrow/MRoundedButton/a92de4d1c5a72825eb7bbec18130dd242e259ffd/AnimateButton/Images.xcassets/image.imageset/image@2x.png -------------------------------------------------------------------------------- /AnimateButton/Images.xcassets/pic.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "pic@2x.png" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /AnimateButton/Images.xcassets/pic.imageset/pic@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcrow/MRoundedButton/a92de4d1c5a72825eb7bbec18130dd242e259ffd/AnimateButton/Images.xcassets/pic.imageset/pic@2x.png -------------------------------------------------------------------------------- /AnimateButton/Vendors/UIImage+ImageEffects.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: UIImage+ImageEffects.h 3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. 4 | Version: 1.0 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2013 Apple Inc. All Rights Reserved. 45 | 46 | 47 | Copyright © 2013 Apple Inc. All rights reserved. 48 | WWDC 2013 License 49 | 50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 51 | Session. Please refer to the applicable WWDC 2013 Session for further 52 | information. 53 | 54 | IMPORTANT: This Apple software is supplied to you by Apple Inc. 55 | ("Apple") in consideration of your agreement to the following terms, and 56 | your use, installation, modification or redistribution of this Apple 57 | software constitutes acceptance of these terms. If you do not agree with 58 | these terms, please do not use, install, modify or redistribute this 59 | Apple software. 60 | 61 | In consideration of your agreement to abide by the following terms, and 62 | subject to these terms, Apple grants you a non-exclusive license, under 63 | Apple's copyrights in this original Apple software (the "Apple 64 | Software"), to use, reproduce, modify and redistribute the Apple 65 | Software, with or without modifications, in source and/or binary forms; 66 | provided that if you redistribute the Apple Software in its entirety and 67 | without modifications, you must retain this notice and the following 68 | text and disclaimers in all such redistributions of the Apple Software. 69 | Neither the name, trademarks, service marks or logos of Apple Inc. may 70 | be used to endorse or promote products derived from the Apple Software 71 | without specific prior written permission from Apple. Except as 72 | expressly stated in this notice, no other rights or licenses, express or 73 | implied, are granted by Apple herein, including but not limited to any 74 | patent rights that may be infringed by your derivative works or by other 75 | works in which the Apple Software may be incorporated. 76 | 77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES 78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE 79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR 80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 82 | 83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | EA1002 93 | 5/3/2013 94 | */ 95 | 96 | #import 97 | 98 | @interface UIImage (ImageEffects) 99 | 100 | - (UIImage *)applyLightEffect; 101 | - (UIImage *)applyExtraLightEffect; 102 | - (UIImage *)applyDarkEffect; 103 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor; 104 | 105 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /AnimateButton/Vendors/UIImage+ImageEffects.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: UIImage+ImageEffects.m 3 | Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. 4 | Version: 1.0 5 | 6 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 7 | Inc. ("Apple") in consideration of your agreement to the following 8 | terms, and your use, installation, modification or redistribution of 9 | this Apple software constitutes acceptance of these terms. If you do 10 | not agree with these terms, please do not use, install, modify or 11 | redistribute this Apple software. 12 | 13 | In consideration of your agreement to abide by the following terms, and 14 | subject to these terms, Apple grants you a personal, non-exclusive 15 | license, under Apple's copyrights in this original Apple software (the 16 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 17 | Software, with or without modifications, in source and/or binary forms; 18 | provided that if you redistribute the Apple Software in its entirety and 19 | without modifications, you must retain this notice and the following 20 | text and disclaimers in all such redistributions of the Apple Software. 21 | Neither the name, trademarks, service marks or logos of Apple Inc. may 22 | be used to endorse or promote products derived from the Apple Software 23 | without specific prior written permission from Apple. Except as 24 | expressly stated in this notice, no other rights or licenses, express or 25 | implied, are granted by Apple herein, including but not limited to any 26 | patent rights that may be infringed by your derivative works or by other 27 | works in which the Apple Software may be incorporated. 28 | 29 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 30 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 31 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 32 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 33 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 34 | 35 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 36 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 37 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 39 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 40 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 41 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 42 | POSSIBILITY OF SUCH DAMAGE. 43 | 44 | Copyright (C) 2013 Apple Inc. All Rights Reserved. 45 | 46 | 47 | Copyright © 2013 Apple Inc. All rights reserved. 48 | WWDC 2013 License 49 | 50 | NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 51 | Session. Please refer to the applicable WWDC 2013 Session for further 52 | information. 53 | 54 | IMPORTANT: This Apple software is supplied to you by Apple Inc. 55 | ("Apple") in consideration of your agreement to the following terms, and 56 | your use, installation, modification or redistribution of this Apple 57 | software constitutes acceptance of these terms. If you do not agree with 58 | these terms, please do not use, install, modify or redistribute this 59 | Apple software. 60 | 61 | In consideration of your agreement to abide by the following terms, and 62 | subject to these terms, Apple grants you a non-exclusive license, under 63 | Apple's copyrights in this original Apple software (the "Apple 64 | Software"), to use, reproduce, modify and redistribute the Apple 65 | Software, with or without modifications, in source and/or binary forms; 66 | provided that if you redistribute the Apple Software in its entirety and 67 | without modifications, you must retain this notice and the following 68 | text and disclaimers in all such redistributions of the Apple Software. 69 | Neither the name, trademarks, service marks or logos of Apple Inc. may 70 | be used to endorse or promote products derived from the Apple Software 71 | without specific prior written permission from Apple. Except as 72 | expressly stated in this notice, no other rights or licenses, express or 73 | implied, are granted by Apple herein, including but not limited to any 74 | patent rights that may be infringed by your derivative works or by other 75 | works in which the Apple Software may be incorporated. 76 | 77 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES 78 | NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE 79 | IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR 80 | A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 81 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 82 | 83 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 84 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 85 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 86 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 87 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 88 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 89 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 90 | POSSIBILITY OF SUCH DAMAGE. 91 | 92 | EA1002 93 | 5/3/2013 94 | */ 95 | 96 | #import "UIImage+ImageEffects.h" 97 | 98 | #import 99 | #import 100 | 101 | 102 | @implementation UIImage (ImageEffects) 103 | 104 | 105 | - (UIImage *)applyLightEffect 106 | { 107 | UIColor *tintColor = [UIColor colorWithWhite:1.0 alpha:0.3]; 108 | return [self applyBlurWithRadius:30 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 109 | } 110 | 111 | 112 | - (UIImage *)applyExtraLightEffect 113 | { 114 | UIColor *tintColor = [UIColor colorWithWhite:0.97 alpha:0.82]; 115 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 116 | } 117 | 118 | 119 | - (UIImage *)applyDarkEffect 120 | { 121 | UIColor *tintColor = [UIColor colorWithWhite:0.11 alpha:0.73]; 122 | return [self applyBlurWithRadius:20 tintColor:tintColor saturationDeltaFactor:1.8 maskImage:nil]; 123 | } 124 | 125 | 126 | - (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor 127 | { 128 | const CGFloat EffectColorAlpha = 0.6; 129 | UIColor *effectColor = tintColor; 130 | int componentCount = CGColorGetNumberOfComponents(tintColor.CGColor); 131 | if (componentCount == 2) { 132 | CGFloat b; 133 | if ([tintColor getWhite:&b alpha:NULL]) { 134 | effectColor = [UIColor colorWithWhite:b alpha:EffectColorAlpha]; 135 | } 136 | } 137 | else { 138 | CGFloat r, g, b; 139 | if ([tintColor getRed:&r green:&g blue:&b alpha:NULL]) { 140 | effectColor = [UIColor colorWithRed:r green:g blue:b alpha:EffectColorAlpha]; 141 | } 142 | } 143 | return [self applyBlurWithRadius:10 tintColor:effectColor saturationDeltaFactor:-1.0 maskImage:nil]; 144 | } 145 | 146 | 147 | - (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage 148 | { 149 | // Check pre-conditions. 150 | if (self.size.width < 1 || self.size.height < 1) { 151 | NSLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self); 152 | return nil; 153 | } 154 | if (!self.CGImage) { 155 | NSLog (@"*** error: image must be backed by a CGImage: %@", self); 156 | return nil; 157 | } 158 | if (maskImage && !maskImage.CGImage) { 159 | NSLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage); 160 | return nil; 161 | } 162 | 163 | CGRect imageRect = { CGPointZero, self.size }; 164 | UIImage *effectImage = self; 165 | 166 | BOOL hasBlur = blurRadius > __FLT_EPSILON__; 167 | BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__; 168 | if (hasBlur || hasSaturationChange) { 169 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 170 | CGContextRef effectInContext = UIGraphicsGetCurrentContext(); 171 | CGContextScaleCTM(effectInContext, 1.0, -1.0); 172 | CGContextTranslateCTM(effectInContext, 0, -self.size.height); 173 | CGContextDrawImage(effectInContext, imageRect, self.CGImage); 174 | 175 | vImage_Buffer effectInBuffer; 176 | effectInBuffer.data = CGBitmapContextGetData(effectInContext); 177 | effectInBuffer.width = CGBitmapContextGetWidth(effectInContext); 178 | effectInBuffer.height = CGBitmapContextGetHeight(effectInContext); 179 | effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext); 180 | 181 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 182 | CGContextRef effectOutContext = UIGraphicsGetCurrentContext(); 183 | vImage_Buffer effectOutBuffer; 184 | effectOutBuffer.data = CGBitmapContextGetData(effectOutContext); 185 | effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext); 186 | effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext); 187 | effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext); 188 | 189 | if (hasBlur) { 190 | // A description of how to compute the box kernel width from the Gaussian 191 | // radius (aka standard deviation) appears in the SVG spec: 192 | // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement 193 | // 194 | // For larger values of 's' (s >= 2.0), an approximation can be used: Three 195 | // successive box-blurs build a piece-wise quadratic convolution kernel, which 196 | // approximates the Gaussian kernel to within roughly 3%. 197 | // 198 | // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) 199 | // 200 | // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. 201 | // 202 | CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale]; 203 | NSUInteger radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5); 204 | if (radius % 2 != 1) { 205 | radius += 1; // force radius to be odd so that the three box-blur methodology works. 206 | } 207 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 208 | vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 209 | vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, radius, radius, 0, kvImageEdgeExtend); 210 | } 211 | BOOL effectImageBuffersAreSwapped = NO; 212 | if (hasSaturationChange) { 213 | CGFloat s = saturationDeltaFactor; 214 | CGFloat floatingPointSaturationMatrix[] = { 215 | 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0, 216 | 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0, 217 | 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0, 218 | 0, 0, 0, 1, 219 | }; 220 | const int32_t divisor = 256; 221 | NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]); 222 | int16_t saturationMatrix[matrixSize]; 223 | for (NSUInteger i = 0; i < matrixSize; ++i) { 224 | saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor); 225 | } 226 | if (hasBlur) { 227 | vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); 228 | effectImageBuffersAreSwapped = YES; 229 | } 230 | else { 231 | vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); 232 | } 233 | } 234 | if (!effectImageBuffersAreSwapped) 235 | effectImage = UIGraphicsGetImageFromCurrentImageContext(); 236 | UIGraphicsEndImageContext(); 237 | 238 | if (effectImageBuffersAreSwapped) 239 | effectImage = UIGraphicsGetImageFromCurrentImageContext(); 240 | UIGraphicsEndImageContext(); 241 | } 242 | 243 | // Set up output context. 244 | UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); 245 | CGContextRef outputContext = UIGraphicsGetCurrentContext(); 246 | CGContextScaleCTM(outputContext, 1.0, -1.0); 247 | CGContextTranslateCTM(outputContext, 0, -self.size.height); 248 | 249 | // Draw base image. 250 | CGContextDrawImage(outputContext, imageRect, self.CGImage); 251 | 252 | // Draw effect image. 253 | if (hasBlur) { 254 | CGContextSaveGState(outputContext); 255 | if (maskImage) { 256 | CGContextClipToMask(outputContext, imageRect, maskImage.CGImage); 257 | } 258 | CGContextDrawImage(outputContext, imageRect, effectImage.CGImage); 259 | CGContextRestoreGState(outputContext); 260 | } 261 | 262 | // Add in color tint. 263 | if (tintColor) { 264 | CGContextSaveGState(outputContext); 265 | CGContextSetFillColorWithColor(outputContext, tintColor.CGColor); 266 | CGContextFillRect(outputContext, imageRect); 267 | CGContextRestoreGState(outputContext); 268 | } 269 | 270 | // Output image is ready. 271 | UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); 272 | UIGraphicsEndImageContext(); 273 | 274 | return outputImage; 275 | } 276 | 277 | 278 | @end 279 | -------------------------------------------------------------------------------- /AnimateButton/Vendors/UIImageView+LBBlurredImage.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+LBBlurredImage.h 3 | // LBBlurredImage 4 | // 5 | // Created by Luca Bernardi on 11/11/12. 6 | // Copyright (c) 2012 Luca Bernardi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef void(^LBBlurredImageCompletionBlock)(void); 12 | 13 | extern CGFloat const kLBBlurredImageDefaultBlurRadius; 14 | 15 | @interface UIImageView (LBBlurredImage) 16 | 17 | /** 18 | Set the blurred version of the provided image to the UIImageView 19 | 20 | @param UIImage the image to blur and set as UIImageView's image 21 | @param CGFLoat the radius of the blur used by the Gaussian filter 22 | @param LBBlurredImageCompletionBlock a completion block called after the image 23 | was blurred and set to the UIImageView (the block is dispatched on main thread) 24 | */ 25 | - (void)setImageToBlur:(UIImage *)image 26 | blurRadius:(CGFloat)blurRadius 27 | completionBlock:(LBBlurredImageCompletionBlock)completion; 28 | 29 | /** 30 | Set the blurred version of the provided image to the UIImageView 31 | with the default blur radius 32 | 33 | @param UIImage the image to blur and set as UIImageView's image 34 | @param LBBlurredImageCompletionBlock a completion block called after the image 35 | was blurred and set to the UIImageView (the block is dispatched on main thread) 36 | */ 37 | - (void)setImageToBlur:(UIImage *)image 38 | completionBlock:(LBBlurredImageCompletionBlock)completion; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /AnimateButton/Vendors/UIImageView+LBBlurredImage.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+LBBlurredImage.m 3 | // LBBlurredImage 4 | // 5 | // Created by Luca Bernardi on 11/11/12. 6 | // Copyright (c) 2012 Luca Bernardi. All rights reserved. 7 | // 8 | 9 | #import "UIImageView+LBBlurredImage.h" 10 | #import "UIImage+ImageEffects.h" 11 | 12 | CGFloat const kLBBlurredImageDefaultBlurRadius = 20.0; 13 | CGFloat const kLBBlurredImageDefaultSaturationDeltaFactor = 1.8; 14 | 15 | @implementation UIImageView (LBBlurredImage) 16 | 17 | #pragma mark - LBBlurredImage Additions 18 | 19 | - (void)setImageToBlur:(UIImage *)image 20 | completionBlock:(LBBlurredImageCompletionBlock)completion 21 | { 22 | [self setImageToBlur:image 23 | blurRadius:kLBBlurredImageDefaultBlurRadius 24 | completionBlock:completion]; 25 | } 26 | 27 | - (void)setImageToBlur:(UIImage *)image 28 | blurRadius:(CGFloat)blurRadius 29 | completionBlock:(LBBlurredImageCompletionBlock) completion 30 | { 31 | NSParameterAssert(image); 32 | NSParameterAssert(blurRadius >= 0); 33 | 34 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 35 | 36 | UIImage *blurredImage = [image applyBlurWithRadius:blurRadius 37 | tintColor:nil 38 | saturationDeltaFactor:kLBBlurredImageDefaultSaturationDeltaFactor 39 | maskImage:nil]; 40 | 41 | dispatch_async(dispatch_get_main_queue(), ^{ 42 | self.image = blurredImage; 43 | if (completion) { 44 | completion(); 45 | } 46 | }); 47 | }); 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /AnimateButton/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AnimateButton 4 | // 5 | // Copyright (c) 2014 Michael WU. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import 26 | 27 | @interface ViewController : UIViewController 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /AnimateButton/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AnimateButton 4 | // 5 | // Copyright (c) 2014 Michael WU. All rights reserved. 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | #import "ViewController.h" 26 | #import "MRoundedButton.h" 27 | #import "UIImageView+LBBlurredImage.h" 28 | 29 | @interface ViewController () 30 | 31 | @end 32 | 33 | @implementation ViewController 34 | 35 | - (void)viewDidLoad 36 | { 37 | [super viewDidLoad]; 38 | 39 | UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; 40 | imageView.contentMode = UIViewContentModeScaleAspectFill; 41 | [imageView setImageToBlur:[UIImage imageNamed:@"pic"] completionBlock:NULL]; 42 | [self.view addSubview:imageView]; 43 | 44 | CGFloat backgroundViewHeight = ceilf(CGRectGetHeight([UIScreen mainScreen].bounds)/ 3.0); 45 | CGFloat backgroundViewWidth = CGRectGetWidth(self.view.bounds); 46 | 47 | NSArray *foregroundColorArray = @[[UIColor whiteColor], 48 | [[UIColor whiteColor] colorWithAlphaComponent:0.5], 49 | [[UIColor blackColor] colorWithAlphaComponent:0.5]]; 50 | NSArray *buttonStyleArray = @[@(MRoundedButtonSubtitle), 51 | @(MRoundedButtonCentralImage), 52 | @(MRoundedButtonCentralImage)]; 53 | for (int i = 0; i < 3; i++) 54 | { 55 | CGRect backgroundRect = CGRectMake(0, 56 | backgroundViewHeight * i, 57 | backgroundViewWidth, 58 | backgroundViewHeight); 59 | MRHollowBackgroundView *backgroundView = [[MRHollowBackgroundView alloc] initWithFrame:backgroundRect]; 60 | backgroundView.foregroundColor = foregroundColorArray[i]; 61 | [self.view addSubview:backgroundView]; 62 | 63 | CGFloat buttonSize = i == 1 ? 50 : 80; 64 | CGRect buttonRect = CGRectMake((backgroundViewWidth - buttonSize) / 2.0, 65 | (backgroundViewHeight - buttonSize) / 2.0, 66 | buttonSize, 67 | buttonSize); 68 | MRoundedButton *button = [[MRoundedButton alloc] initWithFrame:buttonRect 69 | buttonStyle:[buttonStyleArray[i] integerValue] 70 | appearanceIdentifier:[NSString stringWithFormat:@"%d", i + 1]]; 71 | button.backgroundColor = [UIColor clearColor]; 72 | 73 | if (i == 0) 74 | { 75 | button.textLabel.text = @"7"; 76 | button.textLabel.font = [UIFont boldSystemFontOfSize:50]; 77 | button.detailTextLabel.text = @"P Q R S"; 78 | button.detailTextLabel.font = [UIFont systemFontOfSize:10]; 79 | } 80 | else 81 | { 82 | button.imageView.image = [UIImage imageNamed:@"twitter"]; 83 | } 84 | [backgroundView addSubview:button]; 85 | } 86 | } 87 | 88 | - (void)didReceiveMemoryWarning 89 | { 90 | [super didReceiveMemoryWarning]; 91 | // Dispose of any resources that can be recreated. 92 | } 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /AnimateButton/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /AnimateButton/main.m: -------------------------------------------------------------------------------- 1 | // main.m 2 | // AnimateButton 3 | // 4 | // Copyright (c) 2014 Michael WU. All rights reserved. 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | #import "AppDelegate.h" 27 | 28 | int main(int argc, char * argv[]) 29 | { 30 | @autoreleasepool { 31 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /AnimateButton/twitter@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcrow/MRoundedButton/a92de4d1c5a72825eb7bbec18130dd242e259ffd/AnimateButton/twitter@2x.png -------------------------------------------------------------------------------- /AnimateButtonTests/AnimateButtonTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.michaelwu.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /AnimateButtonTests/AnimateButtonTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AnimateButtonTests.m 3 | // AnimateButtonTests 4 | // 5 | // Created by mmt on 2/3/14. 6 | // Copyright (c) 2014 Michael WU. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AnimateButtonTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation AnimateButtonTests 16 | 17 | - (void)setUp 18 | { 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 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /AnimateButtonTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 mrcrow 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. -------------------------------------------------------------------------------- /MRoundedButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // MRoundedButton.h 3 | // 4 | // Copyright (c) 2014 Michael WU. All rights reserved. 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import 25 | 26 | typedef NS_ENUM(NSInteger, MRoundedButtonStyle) { 27 | MRoundedButtonDefault, 28 | MRoundedButtonSubtitle, 29 | MRoundedButtonCentralImage, 30 | MRoundedButtonImageWithSubtitle 31 | }; 32 | 33 | extern CGFloat const MRoundedButtonMaxValue; 34 | 35 | @interface MRoundedButton : UIControl 36 | 37 | @property (readonly, nonatomic) MRoundedButtonStyle mr_buttonStyle; 38 | @property (nonatomic, assign) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; 39 | @property (nonatomic, assign) CGFloat borderWidth UI_APPEARANCE_SELECTOR; 40 | @property (nonatomic, strong) UIColor *borderColor UI_APPEARANCE_SELECTOR; 41 | @property (nonatomic, strong) UIColor *contentColor UI_APPEARANCE_SELECTOR; 42 | @property (nonatomic, strong) UIColor *foregroundColor UI_APPEARANCE_SELECTOR; 43 | @property (nonatomic, strong) UIColor *borderAnimateToColor UI_APPEARANCE_SELECTOR; 44 | @property (nonatomic, strong) UIColor *contentAnimateToColor UI_APPEARANCE_SELECTOR; 45 | @property (nonatomic, strong) UIColor *foregroundAnimateToColor UI_APPEARANCE_SELECTOR; 46 | @property (nonatomic, assign) BOOL restoreSelectedState UI_APPEARANCE_SELECTOR; 47 | 48 | @property (nonatomic, weak) UILabel *textLabel; 49 | @property (nonatomic, weak) UILabel *detailTextLabel; 50 | @property (nonatomic, weak) UIImageView *imageView; 51 | @property (nonatomic, assign) UIEdgeInsets contentEdgeInsets; 52 | 53 | + (instancetype)buttonWithFrame:(CGRect)frame 54 | buttonStyle:(MRoundedButtonStyle)style 55 | appearanceIdentifier:(NSString *)identifier; 56 | - (instancetype)initWithFrame:(CGRect)frame 57 | buttonStyle:(MRoundedButtonStyle)style; 58 | - (instancetype)initWithFrame:(CGRect)frame 59 | buttonStyle:(MRoundedButtonStyle)style 60 | appearanceIdentifier:(NSString *)identifier; 61 | 62 | @end 63 | 64 | extern NSString *const kMRoundedButtonCornerRadius; 65 | extern NSString *const kMRoundedButtonBorderWidth; 66 | extern NSString *const kMRoundedButtonBorderColor; 67 | extern NSString *const kMRoundedButtonContentColor; 68 | extern NSString *const kMRoundedButtonForegroundColor; 69 | extern NSString *const kMRoundedButtonBorderAnimateToColor; 70 | extern NSString *const kMRoundedButtonContentAnimateToColor; 71 | extern NSString *const kMRoundedButtonForegroundAnimateToColor; 72 | extern NSString *const kMRoundedButtonRestoreSelectedState; 73 | 74 | @interface MRoundedButtonAppearanceManager : NSObject 75 | 76 | + (void)registerAppearanceProxy:(NSDictionary *)proxy forIdentifier:(NSString *)identifier; 77 | + (void)unregisterAppearanceProxyIdentier:(NSString *)identifier; 78 | + (NSDictionary *)appearanceForIdentifier:(NSString *)identifier; 79 | 80 | @end 81 | 82 | @interface MRHollowBackgroundView : UIView 83 | 84 | @property (nonatomic, strong) UIColor *foregroundColor; 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /MRoundedButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // MRoundButton.m 3 | // 4 | // Copyright (c) 2014 Michael WU. All rights reserved. 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | #import "MRoundedButton.h" 25 | #import 26 | 27 | CGFloat const MRoundedButtonMaxValue = CGFLOAT_MAX; 28 | 29 | #if !__has_feature(objc_arc) 30 | #error This file must be compiled with ARC. Convert your project to ARC or specify the -fobjc-arc flag. 31 | #endif 32 | 33 | #define MR_MAX_CORNER_RADIUS MIN(CGRectGetWidth(self.bounds) / 2.0, CGRectGetHeight(self.bounds) / 2.0) 34 | #define MR_MAX_BORDER_WIDTH MR_MAX_CORNER_RADIUS 35 | #define MR_MAGICAL_VALUE 0.29 36 | 37 | #define MR_VERSION_IOS_8 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) 38 | 39 | #pragma mark - CGRect extend 40 | static CGRect CGRectEdgeInset(CGRect rect, UIEdgeInsets insets) 41 | { 42 | return CGRectMake(CGRectGetMinX(rect) + insets.left, 43 | CGRectGetMinY(rect) + insets.top, 44 | CGRectGetWidth(rect) - insets.left - insets.right, 45 | CGRectGetHeight(rect) - insets.top - insets.bottom); 46 | } 47 | 48 | #pragma mark - MRTextLayer 49 | @interface MRTextLayer : UIView 50 | @property (nonatomic, strong) UILabel *textLabel; 51 | @end 52 | 53 | @implementation MRTextLayer 54 | 55 | - (instancetype)initWithFrame:(CGRect)frame 56 | { 57 | self = [super initWithFrame:frame]; 58 | if (self) 59 | { 60 | self.textLabel = [[UILabel alloc] initWithFrame:CGRectZero]; 61 | self.textLabel.backgroundColor = [UIColor clearColor]; 62 | self.textLabel.textAlignment = NSTextAlignmentCenter; 63 | self.textLabel.adjustsFontSizeToFitWidth = YES; 64 | self.textLabel.minimumScaleFactor = 0.1; 65 | self.textLabel.numberOfLines = 1; 66 | if (MR_VERSION_IOS_8) 67 | { 68 | self.maskView = self.textLabel; 69 | } 70 | else 71 | { 72 | self.layer.mask = self.textLabel.layer; 73 | } 74 | } 75 | return self; 76 | } 77 | 78 | - (void)layoutSubviews 79 | { 80 | [super layoutSubviews]; 81 | self.textLabel.frame = self.bounds; 82 | } 83 | 84 | @end 85 | 86 | #pragma mark - MRImageLayer 87 | @interface MRImageLayer : UIView 88 | @property (nonatomic, strong) UIImageView *imageView; 89 | @end 90 | 91 | @implementation MRImageLayer 92 | 93 | - (instancetype)initWithFrame:(CGRect)frame 94 | { 95 | self = [super initWithFrame:frame]; 96 | if (self) 97 | { 98 | self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; 99 | self.imageView.contentMode = UIViewContentModeScaleAspectFit; 100 | self.imageView.backgroundColor = [UIColor clearColor]; 101 | if (MR_VERSION_IOS_8) 102 | { 103 | self.maskView = self.imageView; 104 | } 105 | else 106 | { 107 | self.layer.mask = self.imageView.layer; 108 | } 109 | } 110 | return self; 111 | } 112 | 113 | - (void)layoutSubviews 114 | { 115 | [super layoutSubviews]; 116 | self.imageView.frame = self.bounds; 117 | } 118 | 119 | @end 120 | 121 | #pragma mark - MRoundedButton 122 | @interface MRoundedButton () 123 | @property (nonatomic, strong) UIColor *backgroundColorCache; 124 | @property (assign, getter = isTrackingInside) BOOL trackingInside; 125 | @property (nonatomic, strong) UIView *foregroundView; 126 | @property (nonatomic, strong) MRTextLayer *textLayer; 127 | @property (nonatomic, strong) MRTextLayer *detailTextLayer; 128 | @property (nonatomic, strong) MRImageLayer *imageLayer; 129 | 130 | @end 131 | 132 | @implementation MRoundedButton 133 | 134 | - (instancetype)initWithFrame:(CGRect)frame 135 | buttonStyle:(MRoundedButtonStyle)style 136 | appearanceIdentifier:(NSString *)identifier 137 | { 138 | self = [super initWithFrame:frame]; 139 | if (self) 140 | { 141 | self.layer.masksToBounds = YES; 142 | 143 | _mr_buttonStyle = style; 144 | _contentColor = self.tintColor; 145 | _foregroundColor = [UIColor whiteColor]; 146 | _restoreSelectedState = YES; 147 | _trackingInside = NO; 148 | _cornerRadius = 0.0; 149 | _borderWidth = 0.0; 150 | _contentEdgeInsets = UIEdgeInsetsZero; 151 | 152 | self.foregroundView = [[UIView alloc] initWithFrame:CGRectNull]; 153 | self.foregroundView.backgroundColor = self.foregroundColor; 154 | self.foregroundView.layer.masksToBounds = YES; 155 | [self addSubview:self.foregroundView]; 156 | 157 | self.textLayer = [[MRTextLayer alloc] initWithFrame:CGRectNull]; 158 | self.textLayer.backgroundColor = self.contentColor; 159 | [self insertSubview:self.textLayer aboveSubview:self.foregroundView]; 160 | 161 | self.detailTextLayer = [[MRTextLayer alloc] initWithFrame:CGRectNull]; 162 | self.detailTextLayer.backgroundColor = self.contentColor; 163 | [self insertSubview:self.detailTextLayer aboveSubview:self.foregroundView]; 164 | 165 | self.imageLayer = [[MRImageLayer alloc] initWithFrame:CGRectNull]; 166 | self.imageLayer.backgroundColor = self.contentColor; 167 | [self insertSubview:self.imageLayer aboveSubview:self.foregroundView]; 168 | 169 | [self applyAppearanceForIdentifier:identifier]; 170 | } 171 | 172 | return self; 173 | } 174 | 175 | - (instancetype)initWithFrame:(CGRect)frame buttonStyle:(MRoundedButtonStyle)style 176 | { 177 | return [[MRoundedButton alloc] initWithFrame:frame buttonStyle:style appearanceIdentifier:nil]; 178 | } 179 | 180 | - (instancetype)initWithFrame:(CGRect)frame 181 | { 182 | return [[MRoundedButton alloc] initWithFrame:frame buttonStyle:MRoundedButtonDefault appearanceIdentifier:nil]; 183 | } 184 | 185 | + (instancetype)buttonWithFrame:(CGRect)frame buttonStyle:(MRoundedButtonStyle)style appearanceIdentifier:(NSString *)identifier 186 | { 187 | return [[MRoundedButton alloc] initWithFrame:frame buttonStyle:style appearanceIdentifier:identifier]; 188 | } 189 | 190 | - (CGRect)boxingRect 191 | { 192 | CGRect internalRect = CGRectInset(self.bounds, 193 | self.layer.cornerRadius * MR_MAGICAL_VALUE + self.layer.borderWidth, 194 | self.layer.cornerRadius * MR_MAGICAL_VALUE + self.layer.borderWidth); 195 | return CGRectEdgeInset(internalRect, self.contentEdgeInsets); 196 | } 197 | 198 | - (void)layoutSubviews 199 | { 200 | [super layoutSubviews]; 201 | 202 | CGFloat cornerRadius = self.layer.cornerRadius = MAX(MIN(MR_MAX_CORNER_RADIUS, self.cornerRadius), 0); 203 | CGFloat borderWidth = self.layer.borderWidth = MAX(MIN(MR_MAX_BORDER_WIDTH, self.borderWidth), 0); 204 | 205 | _borderWidth = borderWidth; 206 | _cornerRadius = cornerRadius; 207 | 208 | CGFloat layoutBorderWidth = borderWidth == 0.0 ? 0.0 : borderWidth - 0.1; 209 | self.foregroundView.frame = CGRectMake(layoutBorderWidth, 210 | layoutBorderWidth, 211 | CGRectGetWidth(self.bounds) - layoutBorderWidth * 2, 212 | CGRectGetHeight(self.bounds) - layoutBorderWidth * 2); 213 | self.foregroundView.layer.cornerRadius = cornerRadius - borderWidth; 214 | 215 | switch (self.mr_buttonStyle) 216 | { 217 | case MRoundedButtonDefault: 218 | { 219 | self.imageLayer.frame = CGRectNull; 220 | self.detailTextLayer.frame = CGRectNull; 221 | self.textLayer.frame = [self boxingRect]; 222 | } 223 | break; 224 | 225 | case MRoundedButtonSubtitle: 226 | { 227 | self.imageLayer.frame = CGRectNull; 228 | CGRect boxRect = [self boxingRect]; 229 | self.textLayer.frame = CGRectMake(boxRect.origin.x, 230 | boxRect.origin.y, 231 | CGRectGetWidth(boxRect), 232 | CGRectGetHeight(boxRect) * 0.8); 233 | self.detailTextLayer.frame = CGRectMake(boxRect.origin.x, 234 | CGRectGetMaxY(self.textLayer.frame), 235 | CGRectGetWidth(boxRect), 236 | CGRectGetHeight(boxRect) * 0.2); 237 | } 238 | break; 239 | 240 | case MRoundedButtonCentralImage: 241 | { 242 | self.textLayer.frame = CGRectNull; 243 | self.detailTextLayer.frame = CGRectNull; 244 | self.imageLayer.frame = [self boxingRect]; 245 | } 246 | break; 247 | 248 | case MRoundedButtonImageWithSubtitle: 249 | default: 250 | { 251 | CGRect boxRect = [self boxingRect]; 252 | self.textLayer.frame = CGRectNull; 253 | self.imageLayer.frame = CGRectMake(boxRect.origin.x, 254 | boxRect.origin.y, 255 | CGRectGetWidth(boxRect), 256 | CGRectGetHeight(boxRect) * 0.8); 257 | self.detailTextLayer.frame = CGRectMake(boxRect.origin.x, 258 | CGRectGetMaxY(self.imageLayer.frame), 259 | CGRectGetWidth(boxRect), 260 | CGRectGetHeight(boxRect) * 0.2); 261 | } 262 | break; 263 | } 264 | } 265 | 266 | #pragma mark - Appearance 267 | - (void)applyAppearanceForIdentifier:(NSString *)identifier 268 | { 269 | if (![identifier length]) 270 | { 271 | return; 272 | } 273 | 274 | NSDictionary *appearanceProxy = [MRoundedButtonAppearanceManager appearanceForIdentifier:identifier]; 275 | if (!appearanceProxy) 276 | { 277 | return; 278 | } 279 | 280 | [appearanceProxy enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 281 | [self setValue:obj forKey:key]; 282 | }]; 283 | } 284 | 285 | #pragma mark - Setter and getters 286 | - (void)setCornerRadius:(CGFloat)cornerRadius 287 | { 288 | if (_cornerRadius == cornerRadius) 289 | { 290 | return; 291 | } 292 | 293 | _cornerRadius = cornerRadius; 294 | [self setNeedsLayout]; 295 | } 296 | 297 | - (void)setBorderWidth:(CGFloat)borderWidth 298 | { 299 | if (_borderWidth == borderWidth) 300 | { 301 | return; 302 | } 303 | 304 | _borderWidth = borderWidth; 305 | [self setNeedsLayout]; 306 | } 307 | 308 | - (void)setBorderColor:(UIColor *)borderColor 309 | { 310 | _borderColor = borderColor; 311 | self.layer.borderColor = borderColor.CGColor; 312 | } 313 | 314 | - (void)setContentColor:(UIColor *)contentColor 315 | { 316 | _contentColor = contentColor; 317 | self.textLayer.backgroundColor = contentColor; 318 | self.detailTextLayer.backgroundColor = contentColor; 319 | self.imageLayer.backgroundColor = contentColor; 320 | } 321 | 322 | - (void)setForegroundColor:(UIColor *)foregroundColor 323 | { 324 | _foregroundColor = foregroundColor; 325 | self.foregroundView.backgroundColor = foregroundColor; 326 | } 327 | 328 | - (UILabel *)textLabel 329 | { 330 | return self.textLayer.textLabel; 331 | } 332 | 333 | - (UILabel *)detailTextLabel 334 | { 335 | return self.detailTextLayer.textLabel; 336 | } 337 | 338 | - (UIImageView *)imageView 339 | { 340 | return self.imageLayer.imageView; 341 | } 342 | 343 | - (void)setEnabled:(BOOL)enabled 344 | { 345 | [super setEnabled:enabled]; 346 | [UIView animateWithDuration:0.2 animations:^{ 347 | self.foregroundView.alpha = enabled ? 1.0 : 0.5; 348 | }]; 349 | } 350 | 351 | - (void)setSelected:(BOOL)selected 352 | { 353 | [super setSelected:selected]; 354 | if (selected) 355 | { 356 | [self fadeInAnimation]; 357 | } 358 | else 359 | { 360 | [self fadeOutAnimation]; 361 | } 362 | } 363 | 364 | #pragma mark - Fade animation 365 | - (void)fadeInAnimation 366 | { 367 | [UIView animateWithDuration:0.2 animations:^{ 368 | if (self.contentAnimateToColor) 369 | { 370 | self.textLayer.backgroundColor = self.contentAnimateToColor; 371 | self.detailTextLayer.backgroundColor = self.contentAnimateToColor; 372 | self.imageLayer.backgroundColor = self.contentAnimateToColor; 373 | } 374 | 375 | if (self.borderAnimateToColor && 376 | self.foregroundAnimateToColor && 377 | self.borderAnimateToColor == self.foregroundAnimateToColor) 378 | { 379 | self.backgroundColorCache = self.backgroundColor; 380 | self.foregroundView.backgroundColor = [UIColor clearColor]; 381 | self.backgroundColor = self.borderAnimateToColor; 382 | return; 383 | } 384 | 385 | if (self.borderAnimateToColor) 386 | { 387 | self.layer.borderColor = self.borderAnimateToColor.CGColor; 388 | } 389 | 390 | if (self.foregroundAnimateToColor) 391 | { 392 | self.foregroundView.backgroundColor = self.foregroundAnimateToColor; 393 | } 394 | }]; 395 | } 396 | 397 | - (void)fadeOutAnimation 398 | { 399 | [UIView animateWithDuration:0.2 animations:^{ 400 | self.textLayer.backgroundColor = self.contentColor; 401 | self.detailTextLayer.backgroundColor = self.contentColor; 402 | self.imageLayer.backgroundColor = self.contentColor; 403 | 404 | if (self.borderAnimateToColor && 405 | self.foregroundAnimateToColor && 406 | self.borderAnimateToColor == self.foregroundAnimateToColor) 407 | { 408 | self.foregroundView.backgroundColor = self.foregroundColor; 409 | self.backgroundColor = self.backgroundColorCache; 410 | self.backgroundColorCache = nil; 411 | return; 412 | } 413 | 414 | self.foregroundView.backgroundColor = self.foregroundColor; 415 | self.layer.borderColor = self.borderColor.CGColor; 416 | }]; 417 | } 418 | 419 | #pragma mark - Touchs 420 | - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event 421 | { 422 | UIView *touchView = [super hitTest:point withEvent:event]; 423 | if ([self pointInside:point withEvent:event]) 424 | { 425 | return self; 426 | } 427 | 428 | return touchView; 429 | } 430 | 431 | - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event 432 | { 433 | self.trackingInside = YES; 434 | self.selected = !self.selected; 435 | return [super beginTrackingWithTouch:touch withEvent:event]; 436 | } 437 | 438 | - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event 439 | { 440 | BOOL wasTrackingInside = self.trackingInside; 441 | self.trackingInside = [self isTouchInside]; 442 | 443 | if (wasTrackingInside && !self.isTrackingInside) 444 | { 445 | self.selected = !self.selected; 446 | } 447 | else if (!wasTrackingInside && self.isTrackingInside) 448 | { 449 | self.selected = !self.selected; 450 | } 451 | 452 | return [super continueTrackingWithTouch:touch withEvent:event]; 453 | } 454 | 455 | - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event 456 | { 457 | self.trackingInside = [self isTouchInside]; 458 | if (self.isTrackingInside && self.restoreSelectedState) 459 | { 460 | self.selected = !self.selected; 461 | } 462 | 463 | self.trackingInside = NO; 464 | [super endTrackingWithTouch:touch withEvent:event]; 465 | } 466 | 467 | - (void)cancelTrackingWithEvent:(UIEvent *)event 468 | { 469 | self.trackingInside = [self isTouchInside]; 470 | if (self.isTrackingInside) 471 | { 472 | self.selected = !self.selected; 473 | } 474 | 475 | self.trackingInside = NO; 476 | [super cancelTrackingWithEvent:event]; 477 | } 478 | 479 | @end 480 | 481 | #pragma mark - MRoundedButtonAppearanceManager 482 | NSString *const kMRoundedButtonCornerRadius = @"cornerRadius"; 483 | NSString *const kMRoundedButtonBorderWidth = @"borderWidth"; 484 | NSString *const kMRoundedButtonBorderColor = @"borderColor"; 485 | NSString *const kMRoundedButtonBorderAnimateToColor = @"borderAnimateToColor"; 486 | NSString *const kMRoundedButtonContentColor = @"contentColor"; 487 | NSString *const kMRoundedButtonContentAnimateToColor = @"contentAnimateToColor"; 488 | NSString *const kMRoundedButtonForegroundColor = @"foregroundColor"; 489 | NSString *const kMRoundedButtonForegroundAnimateToColor = @"foregroundAnimateToColor"; 490 | NSString *const kMRoundedButtonRestoreSelectedState = @"restoreSelectedState"; 491 | 492 | @interface MRoundedButtonAppearanceManager () 493 | @property (nonatomic, strong) NSMutableDictionary *appearanceProxys; 494 | @end 495 | 496 | @implementation MRoundedButtonAppearanceManager 497 | 498 | + (instancetype)sharedManager 499 | { 500 | static MRoundedButtonAppearanceManager *manager = nil; 501 | static dispatch_once_t onceToken; 502 | dispatch_once(&onceToken, ^{ 503 | manager = [[MRoundedButtonAppearanceManager alloc] init]; 504 | }); 505 | 506 | return manager; 507 | } 508 | 509 | - (instancetype)init 510 | { 511 | self = [super init]; 512 | if (self) 513 | { 514 | self.appearanceProxys = @{}.mutableCopy; 515 | } 516 | 517 | return self; 518 | } 519 | 520 | + (void)registerAppearanceProxy:(NSDictionary *)proxy forIdentifier:(NSString *)identifier 521 | { 522 | if (!proxy || ![identifier length]) 523 | { 524 | return; 525 | } 526 | 527 | MRoundedButtonAppearanceManager *manager = [MRoundedButtonAppearanceManager sharedManager]; 528 | [manager.appearanceProxys setObject:proxy forKey:identifier]; 529 | } 530 | 531 | + (void)unregisterAppearanceProxyIdentier:(NSString *)identifier 532 | { 533 | if (![identifier length]) 534 | { 535 | return; 536 | } 537 | 538 | MRoundedButtonAppearanceManager *manager = [MRoundedButtonAppearanceManager sharedManager]; 539 | [manager.appearanceProxys removeObjectForKey:identifier]; 540 | } 541 | 542 | + (NSDictionary *)appearanceForIdentifier:(NSString *)identifier 543 | { 544 | return [[MRoundedButtonAppearanceManager sharedManager].appearanceProxys objectForKey:identifier]; 545 | } 546 | 547 | @end 548 | 549 | #pragma mark - MRHollowBackgroundView 550 | @implementation MRHollowBackgroundView 551 | 552 | - (instancetype)initWithFrame:(CGRect)frame 553 | { 554 | self = [super initWithFrame:frame]; 555 | if (self) 556 | { 557 | self.opaque = NO; 558 | self.backgroundColor = [UIColor clearColor]; 559 | } 560 | return self; 561 | } 562 | 563 | - (void)setForegroundColor:(UIColor *)foregroundColor 564 | { 565 | if (_foregroundColor == foregroundColor) 566 | { 567 | return; 568 | } 569 | 570 | _foregroundColor = foregroundColor; 571 | [self setNeedsDisplay]; 572 | } 573 | 574 | - (void)layoutSubviews 575 | { 576 | [super layoutSubviews]; 577 | [self setNeedsDisplay]; 578 | } 579 | 580 | - (void)drawRect:(CGRect)rect 581 | { 582 | CGContextRef context = UIGraphicsGetCurrentContext(); 583 | CGContextSaveGState(context); 584 | 585 | [self.foregroundColor setFill]; 586 | 587 | if (self.layer.masksToBounds) 588 | { 589 | UIBezierPath *rectPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:self.layer.cornerRadius]; 590 | CGContextAddPath(context, rectPath.CGPath); 591 | } 592 | else 593 | { 594 | UIBezierPath *rectPath = [UIBezierPath bezierPathWithRect:rect]; 595 | CGContextAddPath(context, rectPath.CGPath); 596 | } 597 | 598 | [self.subviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { 599 | if (view.layer.masksToBounds) 600 | { 601 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:view.frame cornerRadius:view.layer.cornerRadius]; 602 | CGContextAddPath(context, path.CGPath); 603 | } 604 | else 605 | { 606 | UIBezierPath *path = [UIBezierPath bezierPathWithRect:view.frame]; 607 | CGContextAddPath(context, path.CGPath); 608 | } 609 | }]; 610 | 611 | CGContextEOFillPath(context); 612 | CGContextSetAllowsAntialiasing(context, YES); 613 | CGContextSetShouldAntialias(context, YES); 614 | CGContextRestoreGState(context); 615 | } 616 | 617 | @end 618 | -------------------------------------------------------------------------------- /MRoundedButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MRoundedButton" 3 | s.version = "1.1" 4 | s.summary = "UIControl subclass like iOS 7 Phone app button" 5 | s.description = <<-DESC 6 | It is like iOS 7 Phone app button and also provided MRoundedButtonAppearanceManager and MRHollowView for to extend the its usage 7 | DESC 8 | s.homepage = "https://github.com/mrcrow/MRoundedButton" 9 | s.license = { :type => 'MIT', :file => 'LICENSE' } 10 | s.author = { "Michael WU" => "wwz.michael@gmail.com" } 11 | s.source = { :git => "https://github.com/mrcrow/MRoundedButton.git", :tag => s.version.to_s } 12 | 13 | s.platform = :ios, '6.0' 14 | s.requires_arc = true 15 | s.source_files = '*.{h,m}' 16 | s.frameworks = 'Foundation', 'CoreGraphics', 'UIKit' 17 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![image](present.gif) 2 | 3 | > Many thanks to **[@ZevEisenberg](https://github.com/ZevEisenberg)** 4 | 5 | MRoundedButton 6 | ============== 7 | 8 | MRoundedButton is a subclass of UIControl and the appearance is like the iOS 7 **Phone** app button or the button on the **Control Center** and also perform fade in/out animation for touch event. 9 | 10 | Four button styles are suplied: 11 | 12 | MRoundedButtonDefault // central text 13 | MRoundedButtonSubtitle // text with subtitle 14 | MRoundedButtonCentralImage // central image 15 | MRoundedButtonImageWithSubtitle // image with subtitle 16 | 17 | To set a transparent border: 18 | 19 | MRoundedButton *button = [[MRoundedButton alloc] initWithFrame:# 20 | buttonStyle:#]; 21 | button.borderWidth = 2; 22 | button.borderColor = [UIColor clearColor]; 23 | 24 | The value of `borderWidth` and `cornerRadius` are limited to `MIN(BUTTON_WIDTH / 2, BUTTON_HEIGHT / 2)`. 25 | Setting the `cornerRadius` to `FLT_MAX` or `MRoundedButtonMaxValue` can easily make a round button. 26 | 27 | CocoaPods 28 | ========= 29 | 30 | platform :ios, '6.0' 31 | pod "MRoundedButton", "~> 1.0" 32 | 33 | > The 1.1 version is not CocoaPods ready, can download it from [here](https://github.com/mrcrow/MRoundedButton/releases) 34 | 35 | MRoundedButtonAppearanceManager 36 | =============================== 37 | 38 | MRoundedButtonAppearanceManager is the appearance manager for MRoundedButton, each appearance information can be stored in a [NSDictionary](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html) object to make it reusable in the whole project: 39 | 40 | NSDictionary *appearanceProxy = @{kMRoundedButtonCornerRadius : @40, 41 | kMRoundedButtonBorderWidth : @2, 42 | kMRoundedButtonBorderColor : [UIColor clearColor], 43 | kMRoundedButtonContentColor : [UIColor blackColor], 44 | kMRoundedButtonContentAnimationColor : [UIColor whiteColor], 45 | kMRoundedButtonForegroundColor : [UIColor whiteColor], 46 | kMRoundedButtonForegroundAnimationColor : [UIColor clearColor]}; 47 | [MRoundedButtonAppearanceManager registerAppearanceProxy:appearanceProxy1 forIdentifier:#]; 48 | 49 | MRHollowBackgroundView 50 | ============ 51 | 52 | MRHollowBackgroundView can be used to place the MRoundedButton on an image view or something. 53 | > In the drawRect: method, each `subview` of HRHollowView will be cliped to its bounds by `CGContextEOFillPath()`. Then the superview can be displayed from the hollowed shapes. 54 | 55 | Requirement 56 | =========== 57 | * iOS 6.0+ 58 | 59 | Release Notes 60 | ============== 61 | * Ver 1.0 62 | - First Commit 63 | * Ver 1.1 64 | - Make it easy to hightlight the button via `setSelected:` 65 | - Add disabled appearance when set `enabled` to `NO`, need to be improved 66 | - Changed some properties name to make it easy to be understood 67 | - Fixed `userInteractionEnabled` issue 68 | 69 | TODO 70 | ==== 71 | * Disable appearance 72 | 73 | License 74 | ======= 75 | > Permission is hereby granted, free of charge, to any person obtaining a copy 76 | > of this software and associated documentation files (the "Software"), to deal 77 | > in the Software without restriction, including without limitation the rights 78 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 79 | > copies of the Software, and to permit persons to whom the Software is 80 | > furnished to do so, subject to the following conditions: 81 | > 82 | > The above copyright notice and this permission notice shall be included in 83 | > all copies or substantial portions of the Software. 84 | > 85 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 86 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 87 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 88 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 89 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 90 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 91 | > THE SOFTWARE. 92 | 93 | -------------------------------------------------------------------------------- /present.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcrow/MRoundedButton/a92de4d1c5a72825eb7bbec18130dd242e259ffd/present.PNG -------------------------------------------------------------------------------- /present.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcrow/MRoundedButton/a92de4d1c5a72825eb7bbec18130dd242e259ffd/present.gif --------------------------------------------------------------------------------