├── .gitignore ├── DOFavoriteButton-DEMO ├── DOFavoriteButton-DEMO.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── DOFavoriteButton.xcscheme ├── DOFavoriteButton-DEMO │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── heart.imageset │ │ │ ├── Contents.json │ │ │ └── heart.png │ │ ├── like.imageset │ │ │ ├── Contents.json │ │ │ └── like.png │ │ ├── smile.imageset │ │ │ ├── Contents.json │ │ │ └── smile.png │ │ └── star.imageset │ │ │ ├── Contents.json │ │ │ └── star.png │ ├── Info.plist │ └── ViewController.swift └── DOFavoriteButton │ ├── DOFavoriteButton.h │ └── Info.plist ├── DOFavoriteButton.podspec ├── DOFavoriteButton ├── DOFavoriteButton.swift ├── heart.png ├── like.png ├── smile.png └── star.png ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | 33 | Carthage/Build 34 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4F6071201B6366ED0058F570 /* DOFavoriteButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F60711F1B6366ED0058F570 /* DOFavoriteButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 4F60713C1B6367B00058F570 /* DOFavoriteButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F60713B1B6367B00058F570 /* DOFavoriteButton.swift */; }; 12 | 4FBAA7031B4D807F00C8657F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FBAA7021B4D807F00C8657F /* AppDelegate.swift */; }; 13 | 4FBAA7051B4D807F00C8657F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FBAA7041B4D807F00C8657F /* ViewController.swift */; }; 14 | 4FBAA7081B4D807F00C8657F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA7061B4D807F00C8657F /* Main.storyboard */; }; 15 | 4FBAA70A1B4D807F00C8657F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA7091B4D807F00C8657F /* Images.xcassets */; }; 16 | 4FBAA70D1B4D807F00C8657F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA70B1B4D807F00C8657F /* LaunchScreen.xib */; }; 17 | 74018BBB1D86F8CB00B1EC84 /* DOFavoriteButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */; }; 18 | 74018BBC1D86F8CB00B1EC84 /* DOFavoriteButton.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXBuildRule section */ 22 | 4F60713D1B6367C90058F570 /* PBXBuildRule */ = { 23 | isa = PBXBuildRule; 24 | compilerSpec = com.apple.xcode.tools.swift.compiler; 25 | fileType = sourcecode.swift; 26 | isEditable = 1; 27 | outputFiles = ( 28 | ); 29 | script = "# $(SWIFT_EXEC)\n"; 30 | }; 31 | /* End PBXBuildRule section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | 74018BBD1D86F8CB00B1EC84 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 4FBAA6F51B4D807F00C8657F /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = 4F60711A1B6366ED0058F570; 39 | remoteInfo = DOFavoriteButton; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXCopyFilesBuildPhase section */ 44 | 74018BBF1D86F8CB00B1EC84 /* Embed Frameworks */ = { 45 | isa = PBXCopyFilesBuildPhase; 46 | buildActionMask = 2147483647; 47 | dstPath = ""; 48 | dstSubfolderSpec = 10; 49 | files = ( 50 | 74018BBC1D86F8CB00B1EC84 /* DOFavoriteButton.framework in Embed Frameworks */, 51 | ); 52 | name = "Embed Frameworks"; 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXCopyFilesBuildPhase section */ 56 | 57 | /* Begin PBXFileReference section */ 58 | 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DOFavoriteButton.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 4F60711E1B6366ED0058F570 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | 4F60711F1B6366ED0058F570 /* DOFavoriteButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOFavoriteButton.h; sourceTree = ""; }; 61 | 4F60713B1B6367B00058F570 /* DOFavoriteButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DOFavoriteButton.swift; path = ../../DOFavoriteButton/DOFavoriteButton.swift; sourceTree = ""; }; 62 | 4FBAA6FD1B4D807F00C8657F /* DOFavoriteButton-DEMO.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DOFavoriteButton-DEMO.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | 4FBAA7011B4D807F00C8657F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 64 | 4FBAA7021B4D807F00C8657F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 65 | 4FBAA7041B4D807F00C8657F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 66 | 4FBAA7071B4D807F00C8657F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 67 | 4FBAA7091B4D807F00C8657F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 68 | 4FBAA70C1B4D807F00C8657F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | 4F6071171B6366ED0058F570 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | 4FBAA6FA1B4D807F00C8657F /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | 74018BBB1D86F8CB00B1EC84 /* DOFavoriteButton.framework in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | 4F60711C1B6366ED0058F570 /* DOFavoriteButton */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 4F60713B1B6367B00058F570 /* DOFavoriteButton.swift */, 94 | 4F60711F1B6366ED0058F570 /* DOFavoriteButton.h */, 95 | 4F60711D1B6366ED0058F570 /* Supporting Files */, 96 | ); 97 | path = DOFavoriteButton; 98 | sourceTree = ""; 99 | }; 100 | 4F60711D1B6366ED0058F570 /* Supporting Files */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 4F60711E1B6366ED0058F570 /* Info.plist */, 104 | ); 105 | name = "Supporting Files"; 106 | sourceTree = ""; 107 | }; 108 | 4FBAA6F41B4D807F00C8657F = { 109 | isa = PBXGroup; 110 | children = ( 111 | 4FBAA6FF1B4D807F00C8657F /* DOFavoriteButton-DEMO */, 112 | 4F60711C1B6366ED0058F570 /* DOFavoriteButton */, 113 | 4FBAA6FE1B4D807F00C8657F /* Products */, 114 | ); 115 | sourceTree = ""; 116 | }; 117 | 4FBAA6FE1B4D807F00C8657F /* Products */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 4FBAA6FD1B4D807F00C8657F /* DOFavoriteButton-DEMO.app */, 121 | 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */, 122 | ); 123 | name = Products; 124 | sourceTree = ""; 125 | }; 126 | 4FBAA6FF1B4D807F00C8657F /* DOFavoriteButton-DEMO */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 4FBAA7021B4D807F00C8657F /* AppDelegate.swift */, 130 | 4FBAA7041B4D807F00C8657F /* ViewController.swift */, 131 | 4FBAA7061B4D807F00C8657F /* Main.storyboard */, 132 | 4FBAA7091B4D807F00C8657F /* Images.xcassets */, 133 | 4FBAA70B1B4D807F00C8657F /* LaunchScreen.xib */, 134 | 4FBAA7001B4D807F00C8657F /* Supporting Files */, 135 | ); 136 | path = "DOFavoriteButton-DEMO"; 137 | sourceTree = ""; 138 | }; 139 | 4FBAA7001B4D807F00C8657F /* Supporting Files */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 4FBAA7011B4D807F00C8657F /* Info.plist */, 143 | ); 144 | name = "Supporting Files"; 145 | sourceTree = ""; 146 | }; 147 | /* End PBXGroup section */ 148 | 149 | /* Begin PBXHeadersBuildPhase section */ 150 | 4F6071181B6366ED0058F570 /* Headers */ = { 151 | isa = PBXHeadersBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 4F6071201B6366ED0058F570 /* DOFavoriteButton.h in Headers */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXHeadersBuildPhase section */ 159 | 160 | /* Begin PBXNativeTarget section */ 161 | 4F60711A1B6366ED0058F570 /* DOFavoriteButton */ = { 162 | isa = PBXNativeTarget; 163 | buildConfigurationList = 4F6071341B6366ED0058F570 /* Build configuration list for PBXNativeTarget "DOFavoriteButton" */; 164 | buildPhases = ( 165 | 4F6071161B6366ED0058F570 /* Sources */, 166 | 4F6071171B6366ED0058F570 /* Frameworks */, 167 | 4F6071181B6366ED0058F570 /* Headers */, 168 | 4F6071191B6366ED0058F570 /* Resources */, 169 | ); 170 | buildRules = ( 171 | 4F60713D1B6367C90058F570 /* PBXBuildRule */, 172 | ); 173 | dependencies = ( 174 | ); 175 | name = DOFavoriteButton; 176 | productName = DOFavoriteButton; 177 | productReference = 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */; 178 | productType = "com.apple.product-type.framework"; 179 | }; 180 | 4FBAA6FC1B4D807F00C8657F /* DOFavoriteButton-DEMO */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 4FBAA71C1B4D807F00C8657F /* Build configuration list for PBXNativeTarget "DOFavoriteButton-DEMO" */; 183 | buildPhases = ( 184 | 4FBAA6F91B4D807F00C8657F /* Sources */, 185 | 4FBAA6FA1B4D807F00C8657F /* Frameworks */, 186 | 4FBAA6FB1B4D807F00C8657F /* Resources */, 187 | 74018BBF1D86F8CB00B1EC84 /* Embed Frameworks */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | 74018BBE1D86F8CB00B1EC84 /* PBXTargetDependency */, 193 | ); 194 | name = "DOFavoriteButton-DEMO"; 195 | productName = "DOFavoriteButton-DEMO"; 196 | productReference = 4FBAA6FD1B4D807F00C8657F /* DOFavoriteButton-DEMO.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | /* End PBXNativeTarget section */ 200 | 201 | /* Begin PBXProject section */ 202 | 4FBAA6F51B4D807F00C8657F /* Project object */ = { 203 | isa = PBXProject; 204 | attributes = { 205 | LastSwiftMigration = 0700; 206 | LastSwiftUpdateCheck = 0700; 207 | LastUpgradeCheck = 0800; 208 | ORGANIZATIONNAME = "Daiki Okumura"; 209 | TargetAttributes = { 210 | 4F60711A1B6366ED0058F570 = { 211 | CreatedOnToolsVersion = 6.4; 212 | LastSwiftMigration = 0800; 213 | }; 214 | 4FBAA6FC1B4D807F00C8657F = { 215 | CreatedOnToolsVersion = 6.4; 216 | }; 217 | }; 218 | }; 219 | buildConfigurationList = 4FBAA6F81B4D807F00C8657F /* Build configuration list for PBXProject "DOFavoriteButton-DEMO" */; 220 | compatibilityVersion = "Xcode 3.2"; 221 | developmentRegion = English; 222 | hasScannedForEncodings = 0; 223 | knownRegions = ( 224 | en, 225 | Base, 226 | ); 227 | mainGroup = 4FBAA6F41B4D807F00C8657F; 228 | productRefGroup = 4FBAA6FE1B4D807F00C8657F /* Products */; 229 | projectDirPath = ""; 230 | projectRoot = ""; 231 | targets = ( 232 | 4FBAA6FC1B4D807F00C8657F /* DOFavoriteButton-DEMO */, 233 | 4F60711A1B6366ED0058F570 /* DOFavoriteButton */, 234 | ); 235 | }; 236 | /* End PBXProject section */ 237 | 238 | /* Begin PBXResourcesBuildPhase section */ 239 | 4F6071191B6366ED0058F570 /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | 4FBAA6FB1B4D807F00C8657F /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 4FBAA7081B4D807F00C8657F /* Main.storyboard in Resources */, 251 | 4FBAA70D1B4D807F00C8657F /* LaunchScreen.xib in Resources */, 252 | 4FBAA70A1B4D807F00C8657F /* Images.xcassets in Resources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | /* End PBXResourcesBuildPhase section */ 257 | 258 | /* Begin PBXSourcesBuildPhase section */ 259 | 4F6071161B6366ED0058F570 /* Sources */ = { 260 | isa = PBXSourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | 4F60713C1B6367B00058F570 /* DOFavoriteButton.swift in Sources */, 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | 4FBAA6F91B4D807F00C8657F /* Sources */ = { 268 | isa = PBXSourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | 4FBAA7051B4D807F00C8657F /* ViewController.swift in Sources */, 272 | 4FBAA7031B4D807F00C8657F /* AppDelegate.swift in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXSourcesBuildPhase section */ 277 | 278 | /* Begin PBXTargetDependency section */ 279 | 74018BBE1D86F8CB00B1EC84 /* PBXTargetDependency */ = { 280 | isa = PBXTargetDependency; 281 | target = 4F60711A1B6366ED0058F570 /* DOFavoriteButton */; 282 | targetProxy = 74018BBD1D86F8CB00B1EC84 /* PBXContainerItemProxy */; 283 | }; 284 | /* End PBXTargetDependency section */ 285 | 286 | /* Begin PBXVariantGroup section */ 287 | 4FBAA7061B4D807F00C8657F /* Main.storyboard */ = { 288 | isa = PBXVariantGroup; 289 | children = ( 290 | 4FBAA7071B4D807F00C8657F /* Base */, 291 | ); 292 | name = Main.storyboard; 293 | sourceTree = ""; 294 | }; 295 | 4FBAA70B1B4D807F00C8657F /* LaunchScreen.xib */ = { 296 | isa = PBXVariantGroup; 297 | children = ( 298 | 4FBAA70C1B4D807F00C8657F /* Base */, 299 | ); 300 | name = LaunchScreen.xib; 301 | sourceTree = ""; 302 | }; 303 | /* End PBXVariantGroup section */ 304 | 305 | /* Begin XCBuildConfiguration section */ 306 | 4F6071351B6366ED0058F570 /* Debug */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | CLANG_ENABLE_MODULES = YES; 310 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 311 | CURRENT_PROJECT_VERSION = 1; 312 | DEFINES_MODULE = YES; 313 | DYLIB_COMPATIBILITY_VERSION = 1; 314 | DYLIB_CURRENT_VERSION = 1; 315 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 316 | GCC_PREPROCESSOR_DEFINITIONS = ( 317 | "DEBUG=1", 318 | "$(inherited)", 319 | ); 320 | INFOPLIST_FILE = DOFavoriteButton/Info.plist; 321 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 322 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 323 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 324 | PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)"; 325 | PRODUCT_NAME = "$(TARGET_NAME)"; 326 | SKIP_INSTALL = YES; 327 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 328 | SWIFT_VERSION = 3.0; 329 | VERSIONING_SYSTEM = "apple-generic"; 330 | VERSION_INFO_PREFIX = ""; 331 | }; 332 | name = Debug; 333 | }; 334 | 4F6071361B6366ED0058F570 /* Release */ = { 335 | isa = XCBuildConfiguration; 336 | buildSettings = { 337 | CLANG_ENABLE_MODULES = YES; 338 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 339 | CURRENT_PROJECT_VERSION = 1; 340 | DEFINES_MODULE = YES; 341 | DYLIB_COMPATIBILITY_VERSION = 1; 342 | DYLIB_CURRENT_VERSION = 1; 343 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 344 | INFOPLIST_FILE = DOFavoriteButton/Info.plist; 345 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 346 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 348 | PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)"; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | SKIP_INSTALL = YES; 351 | SWIFT_VERSION = 3.0; 352 | VERSIONING_SYSTEM = "apple-generic"; 353 | VERSION_INFO_PREFIX = ""; 354 | }; 355 | name = Release; 356 | }; 357 | 4FBAA71A1B4D807F00C8657F /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | ALWAYS_SEARCH_USER_PATHS = NO; 361 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 362 | CLANG_CXX_LIBRARY = "libc++"; 363 | CLANG_ENABLE_MODULES = YES; 364 | CLANG_ENABLE_OBJC_ARC = YES; 365 | CLANG_WARN_BOOL_CONVERSION = YES; 366 | CLANG_WARN_CONSTANT_CONVERSION = YES; 367 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 368 | CLANG_WARN_EMPTY_BODY = YES; 369 | CLANG_WARN_ENUM_CONVERSION = YES; 370 | CLANG_WARN_INFINITE_RECURSION = YES; 371 | CLANG_WARN_INT_CONVERSION = YES; 372 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 373 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 374 | CLANG_WARN_UNREACHABLE_CODE = YES; 375 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 376 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 377 | COPY_PHASE_STRIP = NO; 378 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 379 | ENABLE_STRICT_OBJC_MSGSEND = YES; 380 | ENABLE_TESTABILITY = YES; 381 | GCC_C_LANGUAGE_STANDARD = gnu99; 382 | GCC_DYNAMIC_NO_PIC = NO; 383 | GCC_NO_COMMON_BLOCKS = YES; 384 | GCC_OPTIMIZATION_LEVEL = 0; 385 | GCC_PREPROCESSOR_DEFINITIONS = ( 386 | "DEBUG=1", 387 | "$(inherited)", 388 | ); 389 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 390 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 391 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 392 | GCC_WARN_UNDECLARED_SELECTOR = YES; 393 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 394 | GCC_WARN_UNUSED_FUNCTION = YES; 395 | GCC_WARN_UNUSED_VARIABLE = YES; 396 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 397 | MTL_ENABLE_DEBUG_INFO = YES; 398 | ONLY_ACTIVE_ARCH = YES; 399 | SDKROOT = iphoneos; 400 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 401 | TARGETED_DEVICE_FAMILY = "1,2"; 402 | }; 403 | name = Debug; 404 | }; 405 | 4FBAA71B1B4D807F00C8657F /* Release */ = { 406 | isa = XCBuildConfiguration; 407 | buildSettings = { 408 | ALWAYS_SEARCH_USER_PATHS = NO; 409 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 410 | CLANG_CXX_LIBRARY = "libc++"; 411 | CLANG_ENABLE_MODULES = YES; 412 | CLANG_ENABLE_OBJC_ARC = YES; 413 | CLANG_WARN_BOOL_CONVERSION = YES; 414 | CLANG_WARN_CONSTANT_CONVERSION = YES; 415 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 416 | CLANG_WARN_EMPTY_BODY = YES; 417 | CLANG_WARN_ENUM_CONVERSION = YES; 418 | CLANG_WARN_INFINITE_RECURSION = YES; 419 | CLANG_WARN_INT_CONVERSION = YES; 420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 421 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 422 | CLANG_WARN_UNREACHABLE_CODE = YES; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 425 | COPY_PHASE_STRIP = NO; 426 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 427 | ENABLE_NS_ASSERTIONS = NO; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | GCC_C_LANGUAGE_STANDARD = gnu99; 430 | GCC_NO_COMMON_BLOCKS = YES; 431 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 432 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 433 | GCC_WARN_UNDECLARED_SELECTOR = YES; 434 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 435 | GCC_WARN_UNUSED_FUNCTION = YES; 436 | GCC_WARN_UNUSED_VARIABLE = YES; 437 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 438 | MTL_ENABLE_DEBUG_INFO = NO; 439 | SDKROOT = iphoneos; 440 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 441 | TARGETED_DEVICE_FAMILY = "1,2"; 442 | VALIDATE_PRODUCT = YES; 443 | }; 444 | name = Release; 445 | }; 446 | 4FBAA71D1B4D807F00C8657F /* Debug */ = { 447 | isa = XCBuildConfiguration; 448 | buildSettings = { 449 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 450 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 451 | INFOPLIST_FILE = "DOFavoriteButton-DEMO/Info.plist"; 452 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 453 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 454 | PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)"; 455 | PRODUCT_NAME = "$(TARGET_NAME)"; 456 | SWIFT_VERSION = 3.0; 457 | }; 458 | name = Debug; 459 | }; 460 | 4FBAA71E1B4D807F00C8657F /* Release */ = { 461 | isa = XCBuildConfiguration; 462 | buildSettings = { 463 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | INFOPLIST_FILE = "DOFavoriteButton-DEMO/Info.plist"; 466 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 467 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 468 | PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)"; 469 | PRODUCT_NAME = "$(TARGET_NAME)"; 470 | SWIFT_VERSION = 3.0; 471 | }; 472 | name = Release; 473 | }; 474 | /* End XCBuildConfiguration section */ 475 | 476 | /* Begin XCConfigurationList section */ 477 | 4F6071341B6366ED0058F570 /* Build configuration list for PBXNativeTarget "DOFavoriteButton" */ = { 478 | isa = XCConfigurationList; 479 | buildConfigurations = ( 480 | 4F6071351B6366ED0058F570 /* Debug */, 481 | 4F6071361B6366ED0058F570 /* Release */, 482 | ); 483 | defaultConfigurationIsVisible = 0; 484 | defaultConfigurationName = Release; 485 | }; 486 | 4FBAA6F81B4D807F00C8657F /* Build configuration list for PBXProject "DOFavoriteButton-DEMO" */ = { 487 | isa = XCConfigurationList; 488 | buildConfigurations = ( 489 | 4FBAA71A1B4D807F00C8657F /* Debug */, 490 | 4FBAA71B1B4D807F00C8657F /* Release */, 491 | ); 492 | defaultConfigurationIsVisible = 0; 493 | defaultConfigurationName = Release; 494 | }; 495 | 4FBAA71C1B4D807F00C8657F /* Build configuration list for PBXNativeTarget "DOFavoriteButton-DEMO" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 4FBAA71D1B4D807F00C8657F /* Debug */, 499 | 4FBAA71E1B4D807F00C8657F /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | /* End XCConfigurationList section */ 505 | }; 506 | rootObject = 4FBAA6F51B4D807F00C8657F /* Project object */; 507 | } 508 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO.xcodeproj/xcshareddata/xcschemes/DOFavoriteButton.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DOFavoriteButton-DEMO 4 | // 5 | // Created by Daiki Okumura on 2015/07/09. 6 | // Copyright (c) 2015 Daiki Okumura. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 43 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/heart.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "heart.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/heart.imageset/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/heart.imageset/heart.png -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/like.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "like.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/like.imageset/like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/like.imageset/like.png -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/smile.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "smile.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/smile.imageset/smile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/smile.imageset/smile.png -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/star.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "star.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/star.imageset/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Images.xcassets/star.imageset/star.png -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DOFavoriteButton-DEMO 4 | // 5 | // Created by Daiki Okumura on 2015/07/09. 6 | // Copyright (c) 2015 Daiki Okumura. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import DOFavoriteButton 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet var heartButton: DOFavoriteButton! 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | // Do any additional setup after loading the view, typically from a nib. 18 | 19 | let width = (self.view.frame.width - 44) / 4 20 | var x = width / 2 21 | let y = self.view.frame.height / 2 - 22 22 | 23 | // star button 24 | let starButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "star")) 25 | starButton.addTarget(self, action: #selector(self.tappedButton), for: .touchUpInside) 26 | self.view.addSubview(starButton) 27 | x += width 28 | 29 | // heart button 30 | let heartButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "heart")) 31 | heartButton.imageColorOn = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0) 32 | heartButton.circleColor = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0) 33 | heartButton.lineColor = UIColor(red: 226/255, green: 96/255, blue: 96/255, alpha: 1.0) 34 | heartButton.addTarget(self, action: #selector(self.tappedButton), for: .touchUpInside) 35 | self.view.addSubview(heartButton) 36 | x += width 37 | 38 | // like button 39 | let likeButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "like")) 40 | likeButton.imageColorOn = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0) 41 | likeButton.circleColor = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0) 42 | likeButton.lineColor = UIColor(red: 41/255, green: 128/255, blue: 185/255, alpha: 1.0) 43 | likeButton.addTarget(self, action: #selector(self.tappedButton), for: .touchUpInside) 44 | self.view.addSubview(likeButton) 45 | x += width 46 | 47 | // smile button 48 | let smileButton = DOFavoriteButton(frame: CGRect(x: x, y: y, width: 44, height: 44), image: UIImage(named: "smile")) 49 | smileButton.imageColorOn = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0) 50 | smileButton.circleColor = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0) 51 | smileButton.lineColor = UIColor(red: 45/255, green: 195/255, blue: 106/255, alpha: 1.0) 52 | smileButton.addTarget(self, action: #selector(self.tappedButton), for: .touchUpInside) 53 | self.view.addSubview(smileButton) 54 | 55 | self.heartButton.addTarget(self, action: #selector(self.tappedButton), for: .touchUpInside) 56 | 57 | } 58 | 59 | override func didReceiveMemoryWarning() { 60 | super.didReceiveMemoryWarning() 61 | // Dispose of any resources that can be recreated. 62 | } 63 | 64 | func tappedButton(sender: DOFavoriteButton) { 65 | if sender.isSelected { 66 | sender.deselect() 67 | } else { 68 | sender.select() 69 | } 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton/DOFavoriteButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // DOFavoriteButton.h 3 | // DOFavoriteButton 4 | // 5 | // Created by Daiki Okumura on 2015/07/25. 6 | // Copyright (c) 2015 Daiki Okumura. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for DOFavoriteButton. 12 | FOUNDATION_EXPORT double DOFavoriteButtonVersionNumber; 13 | 14 | //! Project version string for DOFavoriteButton. 15 | FOUNDATION_EXPORT const unsigned char DOFavoriteButtonVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /DOFavoriteButton-DEMO/DOFavoriteButton/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /DOFavoriteButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "DOFavoriteButton" 3 | s.version = "0.0.4" 4 | s.summary = "Cute Animated Button written in Swift. It could be just right for favorite buttons!" 5 | s.homepage = "https://github.com/okmr-d/DOFavoriteButton" 6 | s.screenshots = "https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/demo.gif" 7 | s.license = { :type => "MIT", :file => "LICENSE" } 8 | s.author = { "Daiki Okumura" => "daiki.okumura@gmail.com" } 9 | s.social_media_url = "http://twitter.com/okmr_d" 10 | s.platform = :ios, "8.0" 11 | s.source = { :git => "https://github.com/okmr-d/DOFavoriteButton.git", :tag => s.version.to_s } 12 | s.source_files = "DOFavoriteButton/*.swift" 13 | s.resources = "DOFavoriteButton/*.png" 14 | s.framework = "UIKit" 15 | s.requires_arc = true 16 | end 17 | -------------------------------------------------------------------------------- /DOFavoriteButton/DOFavoriteButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DOFavoriteButton.swift 3 | // DOFavoriteButton 4 | // 5 | // Created by Daiki Okumura on 2015/07/09. 6 | // Copyright (c) 2015 Daiki Okumura. All rights reserved. 7 | // 8 | // This software is released under the MIT License. 9 | // http://opensource.org/licenses/mit-license.php 10 | // 11 | 12 | import UIKit 13 | 14 | @IBDesignable 15 | open class DOFavoriteButton: UIButton { 16 | 17 | fileprivate var imageShape: CAShapeLayer! 18 | @IBInspectable open var image: UIImage! { 19 | didSet { 20 | createLayers(image: image) 21 | } 22 | } 23 | @IBInspectable open var imageColorOn: UIColor! = UIColor(red: 255/255, green: 172/255, blue: 51/255, alpha: 1.0) { 24 | didSet { 25 | if (isSelected) { 26 | imageShape.fillColor = imageColorOn.cgColor 27 | } 28 | } 29 | } 30 | @IBInspectable open var imageColorOff: UIColor! = UIColor(red: 136/255, green: 153/255, blue: 166/255, alpha: 1.0) { 31 | didSet { 32 | if (!isSelected) { 33 | imageShape.fillColor = imageColorOff.cgColor 34 | } 35 | } 36 | } 37 | 38 | fileprivate var circleShape: CAShapeLayer! 39 | fileprivate var circleMask: CAShapeLayer! 40 | @IBInspectable open var circleColor: UIColor! = UIColor(red: 255/255, green: 172/255, blue: 51/255, alpha: 1.0) { 41 | didSet { 42 | circleShape.fillColor = circleColor.cgColor 43 | } 44 | } 45 | 46 | fileprivate var lines: [CAShapeLayer]! 47 | @IBInspectable open var lineColor: UIColor! = UIColor(red: 250/255, green: 120/255, blue: 68/255, alpha: 1.0) { 48 | didSet { 49 | for line in lines { 50 | line.strokeColor = lineColor.cgColor 51 | } 52 | } 53 | } 54 | 55 | fileprivate let circleTransform = CAKeyframeAnimation(keyPath: "transform") 56 | fileprivate let circleMaskTransform = CAKeyframeAnimation(keyPath: "transform") 57 | fileprivate let lineStrokeStart = CAKeyframeAnimation(keyPath: "strokeStart") 58 | fileprivate let lineStrokeEnd = CAKeyframeAnimation(keyPath: "strokeEnd") 59 | fileprivate let lineOpacity = CAKeyframeAnimation(keyPath: "opacity") 60 | fileprivate let imageTransform = CAKeyframeAnimation(keyPath: "transform") 61 | 62 | @IBInspectable open var duration: Double = 1.0 { 63 | didSet { 64 | circleTransform.duration = 0.333 * duration // 0.0333 * 10 65 | circleMaskTransform.duration = 0.333 * duration // 0.0333 * 10 66 | lineStrokeStart.duration = 0.6 * duration //0.0333 * 18 67 | lineStrokeEnd.duration = 0.6 * duration //0.0333 * 18 68 | lineOpacity.duration = 1.0 * duration //0.0333 * 30 69 | imageTransform.duration = 1.0 * duration //0.0333 * 30 70 | } 71 | } 72 | 73 | override open var isSelected : Bool { 74 | didSet { 75 | if (isSelected != oldValue) { 76 | if isSelected { 77 | imageShape.fillColor = imageColorOn.cgColor 78 | } else { 79 | deselect() 80 | } 81 | } 82 | } 83 | } 84 | 85 | public convenience init() { 86 | self.init(frame: CGRect.zero) 87 | } 88 | 89 | public override convenience init(frame: CGRect) { 90 | self.init(frame: frame, image: UIImage()) 91 | } 92 | 93 | public init(frame: CGRect, image: UIImage!) { 94 | super.init(frame: frame) 95 | self.image = image 96 | createLayers(image: image) 97 | addTargets() 98 | } 99 | 100 | public required init(coder aDecoder: NSCoder) { 101 | super.init(coder: aDecoder)! 102 | createLayers(image: UIImage()) 103 | addTargets() 104 | } 105 | 106 | fileprivate func createLayers(image: UIImage!) { 107 | self.layer.sublayers = nil 108 | 109 | let imageFrame = CGRect(x: frame.size.width / 2 - frame.size.width / 4, y: frame.size.height / 2 - frame.size.height / 4, width: frame.size.width / 2, height: frame.size.height / 2) 110 | let imgCenterPoint = CGPoint(x: imageFrame.midX, y: imageFrame.midY) 111 | let lineFrame = CGRect(x: imageFrame.origin.x - imageFrame.width / 4, y: imageFrame.origin.y - imageFrame.height / 4 , width: imageFrame.width * 1.5, height: imageFrame.height * 1.5) 112 | 113 | //=============== 114 | // circle layer 115 | //=============== 116 | circleShape = CAShapeLayer() 117 | circleShape.bounds = imageFrame 118 | circleShape.position = imgCenterPoint 119 | circleShape.path = UIBezierPath(ovalIn: imageFrame).cgPath 120 | circleShape.fillColor = circleColor.cgColor 121 | circleShape.transform = CATransform3DMakeScale(0.0, 0.0, 1.0) 122 | self.layer.addSublayer(circleShape) 123 | 124 | circleMask = CAShapeLayer() 125 | circleMask.bounds = imageFrame 126 | circleMask.position = imgCenterPoint 127 | circleMask.fillRule = kCAFillRuleEvenOdd 128 | circleShape.mask = circleMask 129 | 130 | let maskPath = UIBezierPath(rect: imageFrame) 131 | maskPath.addArc(withCenter: imgCenterPoint, radius: 0.1, startAngle: CGFloat(0.0), endAngle: CGFloat(M_PI * 2), clockwise: true) 132 | circleMask.path = maskPath.cgPath 133 | 134 | //=============== 135 | // line layer 136 | //=============== 137 | lines = [] 138 | for i in 0 ..< 5 { 139 | let line = CAShapeLayer() 140 | line.bounds = lineFrame 141 | line.position = imgCenterPoint 142 | line.masksToBounds = true 143 | line.actions = ["strokeStart": NSNull(), "strokeEnd": NSNull()] 144 | line.strokeColor = lineColor.cgColor 145 | line.lineWidth = 1.25 146 | line.miterLimit = 1.25 147 | line.path = { 148 | let path = CGMutablePath() 149 | path.move(to: CGPoint(x: lineFrame.midX, y: lineFrame.midY)) 150 | path.addLine(to: CGPoint(x: lineFrame.origin.x + lineFrame.width / 2, y: lineFrame.origin.y)) 151 | return path 152 | }() 153 | line.lineCap = kCALineCapRound 154 | line.lineJoin = kCALineJoinRound 155 | line.strokeStart = 0.0 156 | line.strokeEnd = 0.0 157 | line.opacity = 0.0 158 | line.transform = CATransform3DMakeRotation(CGFloat(M_PI) / 5 * (CGFloat(i) * 2 + 1), 0.0, 0.0, 1.0) 159 | self.layer.addSublayer(line) 160 | lines.append(line) 161 | } 162 | 163 | //=============== 164 | // image layer 165 | //=============== 166 | imageShape = CAShapeLayer() 167 | imageShape.bounds = imageFrame 168 | imageShape.position = imgCenterPoint 169 | imageShape.path = UIBezierPath(rect: imageFrame).cgPath 170 | imageShape.fillColor = imageColorOff.cgColor 171 | imageShape.actions = ["fillColor": NSNull()] 172 | self.layer.addSublayer(imageShape) 173 | 174 | imageShape.mask = CALayer() 175 | imageShape.mask!.contents = image.cgImage 176 | imageShape.mask!.bounds = imageFrame 177 | imageShape.mask!.position = imgCenterPoint 178 | 179 | //============================== 180 | // circle transform animation 181 | //============================== 182 | circleTransform.duration = 0.333 // 0.0333 * 10 183 | circleTransform.values = [ 184 | NSValue(caTransform3D: CATransform3DMakeScale(0.0, 0.0, 1.0)), // 0/10 185 | NSValue(caTransform3D: CATransform3DMakeScale(0.5, 0.5, 1.0)), // 1/10 186 | NSValue(caTransform3D: CATransform3DMakeScale(1.0, 1.0, 1.0)), // 2/10 187 | NSValue(caTransform3D: CATransform3DMakeScale(1.2, 1.2, 1.0)), // 3/10 188 | NSValue(caTransform3D: CATransform3DMakeScale(1.3, 1.3, 1.0)), // 4/10 189 | NSValue(caTransform3D: CATransform3DMakeScale(1.37, 1.37, 1.0)), // 5/10 190 | NSValue(caTransform3D: CATransform3DMakeScale(1.4, 1.4, 1.0)), // 6/10 191 | NSValue(caTransform3D: CATransform3DMakeScale(1.4, 1.4, 1.0)) // 10/10 192 | ] 193 | circleTransform.keyTimes = [ 194 | 0.0, // 0/10 195 | 0.1, // 1/10 196 | 0.2, // 2/10 197 | 0.3, // 3/10 198 | 0.4, // 4/10 199 | 0.5, // 5/10 200 | 0.6, // 6/10 201 | 1.0 // 10/10 202 | ] 203 | 204 | circleMaskTransform.duration = 0.333 // 0.0333 * 10 205 | circleMaskTransform.values = [ 206 | NSValue(caTransform3D: CATransform3DIdentity), // 0/10 207 | NSValue(caTransform3D: CATransform3DIdentity), // 2/10 208 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 1.25, imageFrame.height * 1.25, 1.0)), // 3/10 209 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 2.688, imageFrame.height * 2.688, 1.0)), // 4/10 210 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 3.923, imageFrame.height * 3.923, 1.0)), // 5/10 211 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 4.375, imageFrame.height * 4.375, 1.0)), // 6/10 212 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 4.731, imageFrame.height * 4.731, 1.0)), // 7/10 213 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 5.0, imageFrame.height * 5.0, 1.0)), // 9/10 214 | NSValue(caTransform3D: CATransform3DMakeScale(imageFrame.width * 5.0, imageFrame.height * 5.0, 1.0)) // 10/10 215 | ] 216 | circleMaskTransform.keyTimes = [ 217 | 0.0, // 0/10 218 | 0.2, // 2/10 219 | 0.3, // 3/10 220 | 0.4, // 4/10 221 | 0.5, // 5/10 222 | 0.6, // 6/10 223 | 0.7, // 7/10 224 | 0.9, // 9/10 225 | 1.0 // 10/10 226 | ] 227 | 228 | //============================== 229 | // line stroke animation 230 | //============================== 231 | lineStrokeStart.duration = 0.6 //0.0333 * 18 232 | lineStrokeStart.values = [ 233 | 0.0, // 0/18 234 | 0.0, // 1/18 235 | 0.18, // 2/18 236 | 0.2, // 3/18 237 | 0.26, // 4/18 238 | 0.32, // 5/18 239 | 0.4, // 6/18 240 | 0.6, // 7/18 241 | 0.71, // 8/18 242 | 0.89, // 17/18 243 | 0.92 // 18/18 244 | ] 245 | lineStrokeStart.keyTimes = [ 246 | 0.0, // 0/18 247 | 0.056, // 1/18 248 | 0.111, // 2/18 249 | 0.167, // 3/18 250 | 0.222, // 4/18 251 | 0.278, // 5/18 252 | 0.333, // 6/18 253 | 0.389, // 7/18 254 | 0.444, // 8/18 255 | 0.944, // 17/18 256 | 1.0, // 18/18 257 | ] 258 | 259 | lineStrokeEnd.duration = 0.6 //0.0333 * 18 260 | lineStrokeEnd.values = [ 261 | 0.0, // 0/18 262 | 0.0, // 1/18 263 | 0.32, // 2/18 264 | 0.48, // 3/18 265 | 0.64, // 4/18 266 | 0.68, // 5/18 267 | 0.92, // 17/18 268 | 0.92 // 18/18 269 | ] 270 | lineStrokeEnd.keyTimes = [ 271 | 0.0, // 0/18 272 | 0.056, // 1/18 273 | 0.111, // 2/18 274 | 0.167, // 3/18 275 | 0.222, // 4/18 276 | 0.278, // 5/18 277 | 0.944, // 17/18 278 | 1.0, // 18/18 279 | ] 280 | 281 | lineOpacity.duration = 1.0 //0.0333 * 30 282 | lineOpacity.values = [ 283 | 1.0, // 0/30 284 | 1.0, // 12/30 285 | 0.0 // 17/30 286 | ] 287 | lineOpacity.keyTimes = [ 288 | 0.0, // 0/30 289 | 0.4, // 12/30 290 | 0.567 // 17/30 291 | ] 292 | 293 | //============================== 294 | // image transform animation 295 | //============================== 296 | imageTransform.duration = 1.0 //0.0333 * 30 297 | imageTransform.values = [ 298 | NSValue(caTransform3D: CATransform3DMakeScale(0.0, 0.0, 1.0)), // 0/30 299 | NSValue(caTransform3D: CATransform3DMakeScale(0.0, 0.0, 1.0)), // 3/30 300 | NSValue(caTransform3D: CATransform3DMakeScale(1.2, 1.2, 1.0)), // 9/30 301 | NSValue(caTransform3D: CATransform3DMakeScale(1.25, 1.25, 1.0)), // 10/30 302 | NSValue(caTransform3D: CATransform3DMakeScale(1.2, 1.2, 1.0)), // 11/30 303 | NSValue(caTransform3D: CATransform3DMakeScale(0.9, 0.9, 1.0)), // 14/30 304 | NSValue(caTransform3D: CATransform3DMakeScale(0.875, 0.875, 1.0)), // 15/30 305 | NSValue(caTransform3D: CATransform3DMakeScale(0.875, 0.875, 1.0)), // 16/30 306 | NSValue(caTransform3D: CATransform3DMakeScale(0.9, 0.9, 1.0)), // 17/30 307 | NSValue(caTransform3D: CATransform3DMakeScale(1.013, 1.013, 1.0)), // 20/30 308 | NSValue(caTransform3D: CATransform3DMakeScale(1.025, 1.025, 1.0)), // 21/30 309 | NSValue(caTransform3D: CATransform3DMakeScale(1.013, 1.013, 1.0)), // 22/30 310 | NSValue(caTransform3D: CATransform3DMakeScale(0.96, 0.96, 1.0)), // 25/30 311 | NSValue(caTransform3D: CATransform3DMakeScale(0.95, 0.95, 1.0)), // 26/30 312 | NSValue(caTransform3D: CATransform3DMakeScale(0.96, 0.96, 1.0)), // 27/30 313 | NSValue(caTransform3D: CATransform3DMakeScale(0.99, 0.99, 1.0)), // 29/30 314 | NSValue(caTransform3D: CATransform3DIdentity) // 30/30 315 | ] 316 | imageTransform.keyTimes = [ 317 | 0.0, // 0/30 318 | 0.1, // 3/30 319 | 0.3, // 9/30 320 | 0.333, // 10/30 321 | 0.367, // 11/30 322 | 0.467, // 14/30 323 | 0.5, // 15/30 324 | 0.533, // 16/30 325 | 0.567, // 17/30 326 | 0.667, // 20/30 327 | 0.7, // 21/30 328 | 0.733, // 22/30 329 | 0.833, // 25/30 330 | 0.867, // 26/30 331 | 0.9, // 27/30 332 | 0.967, // 29/30 333 | 1.0 // 30/30 334 | ] 335 | } 336 | 337 | fileprivate func addTargets() { 338 | //=============== 339 | // add target 340 | //=============== 341 | self.addTarget(self, action: #selector(DOFavoriteButton.touchDown(_:)), for: UIControlEvents.touchDown) 342 | self.addTarget(self, action: #selector(DOFavoriteButton.touchUpInside(_:)), for: UIControlEvents.touchUpInside) 343 | self.addTarget(self, action: #selector(DOFavoriteButton.touchDragExit(_:)), for: UIControlEvents.touchDragExit) 344 | self.addTarget(self, action: #selector(DOFavoriteButton.touchDragEnter(_:)), for: UIControlEvents.touchDragEnter) 345 | self.addTarget(self, action: #selector(DOFavoriteButton.touchCancel(_:)), for: UIControlEvents.touchCancel) 346 | } 347 | 348 | func touchDown(_ sender: DOFavoriteButton) { 349 | self.layer.opacity = 0.4 350 | } 351 | func touchUpInside(_ sender: DOFavoriteButton) { 352 | self.layer.opacity = 1.0 353 | } 354 | func touchDragExit(_ sender: DOFavoriteButton) { 355 | self.layer.opacity = 1.0 356 | } 357 | func touchDragEnter(_ sender: DOFavoriteButton) { 358 | self.layer.opacity = 0.4 359 | } 360 | func touchCancel(_ sender: DOFavoriteButton) { 361 | self.layer.opacity = 1.0 362 | } 363 | 364 | open func select() { 365 | isSelected = true 366 | imageShape.fillColor = imageColorOn.cgColor 367 | 368 | CATransaction.begin() 369 | 370 | circleShape.add(circleTransform, forKey: "transform") 371 | circleMask.add(circleMaskTransform, forKey: "transform") 372 | imageShape.add(imageTransform, forKey: "transform") 373 | 374 | for i in 0 ..< 5 { 375 | lines[i].add(lineStrokeStart, forKey: "strokeStart") 376 | lines[i].add(lineStrokeEnd, forKey: "strokeEnd") 377 | lines[i].add(lineOpacity, forKey: "opacity") 378 | } 379 | 380 | CATransaction.commit() 381 | } 382 | 383 | open func deselect() { 384 | isSelected = false 385 | imageShape.fillColor = imageColorOff.cgColor 386 | 387 | // remove all animations 388 | circleShape.removeAllAnimations() 389 | circleMask.removeAllAnimations() 390 | imageShape.removeAllAnimations() 391 | lines[0].removeAllAnimations() 392 | lines[1].removeAllAnimations() 393 | lines[2].removeAllAnimations() 394 | lines[3].removeAllAnimations() 395 | lines[4].removeAllAnimations() 396 | } 397 | } 398 | -------------------------------------------------------------------------------- /DOFavoriteButton/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton/heart.png -------------------------------------------------------------------------------- /DOFavoriteButton/like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton/like.png -------------------------------------------------------------------------------- /DOFavoriteButton/smile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton/smile.png -------------------------------------------------------------------------------- /DOFavoriteButton/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/okmr-d/DOFavoriteButton/43c65253d4c14e596a511354ca0e0aac0ec2bd5c/DOFavoriteButton/star.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Daiki Okumura 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DOFavoriteButton 2 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 3 | [![Version](https://img.shields.io/cocoapods/v/DOFavoriteButton.svg?style=flat)](http://cocoapods.org/pods/DOFavoriteButton) 4 | [![Platform](https://img.shields.io/cocoapods/p/DOFavoriteButton.svg?style=flat)](http://cocoapods.org/pods/DOFavoriteButton) 5 | [![License](https://img.shields.io/cocoapods/l/DOFavoriteButton.svg?style=flat)](https://github.com/okmr-d/DOFavoriteButton/blob/master/LICENSE) 6 | 7 | Cute Animated Button written in Swift. 8 | It could be just right for favorite buttons! 9 | ![Demo](https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/demo.gif) 10 | 11 | ## Requirements 12 | * iOS 7.0+ 13 | * Swift 1.2 14 | 15 | ## Installation 16 | #### Carthage 17 | Add the following line to your `Cartfile`: 18 | ``` 19 | github "okmr-d/DOFavoriteButton" 20 | ``` 21 | 22 | #### CocoaPods 23 | Add the following line to your `Podfile`: 24 | ``` 25 | pod 'DOFavoriteButton' 26 | ``` 27 | 28 | #### Manual 29 | Just drag DOFavoriteButton.swift to your project. 30 | 31 | ## How to use 32 | #### 1. Add a flat icon image 33 | ![Flat Icon Image](https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/flatIconImage.png) 34 | 35 | #### 2. Create a button 36 | ##### ・By coding 37 | ```swift 38 | let button = DOFavoriteButton(frame: CGRectMake(0, 0, 44, 44), image: UIImage(named: "star.png")) 39 | self.view.addSubview(button) 40 | ``` 41 | 42 | ##### ・By using Storyboard or XIB 43 | 1. Add Button object and set Custom Class `DOFavoriteButton` 44 | ![via Storyboard](https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/storyboard.png) 45 | 46 | 2. Connect Outlet 47 | ![connect outlet](https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/connect.png) 48 | 49 | #### 3. Add tapped function 50 | ```swift 51 | button.addTarget(self, action: Selector("tapped:"), forControlEvents: .TouchUpInside) 52 | ``` 53 | ```swift 54 | func tapped(sender: DOFavoriteButton) { 55 | if sender.selected { 56 | // deselect 57 | sender.deselect() 58 | } else { 59 | // select with animation 60 | sender.select() 61 | } 62 | } 63 | ``` 64 | 65 | ## Customize 66 | You can change button color & animation duration: 67 | ```swift 68 | button.imageColorOff = UIColor.brownColor() 69 | button.imageColorOn = UIColor.redColor() 70 | button.circleColor = UIColor.greenColor() 71 | button.lineColor = UIColor.blueColor() 72 | button.duration = 3.0 // default: 1.0 73 | ``` 74 | Result: 75 | ![Customize](https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/changeColor.gif) 76 | 77 | ## DEMO 78 | There is a demo project added to this repository, so you can see how it works. 79 | 80 | ## Credit/Inspiration 81 | DOFavoriteButton was inspired by [Twitter's iOS App](https://itunes.apple.com/us/app/twitter/id333903271). 82 | 83 | ## License 84 | This software is released under the MIT License. 85 | --------------------------------------------------------------------------------