├── .gitignore ├── .swift-version ├── EasySocialButton.podspec ├── EasySocialButton.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── EasySocialButton ├── .DS_Store ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── background.imageset │ │ ├── Contents.json │ │ └── background.jpg │ ├── ic_facebook.imageset │ │ ├── Contents.json │ │ ├── FB-f-Logo__white_72.png │ │ ├── FB-f-Logo__white_72@2x.png │ │ └── FB-f-Logo__white_72@3x.png │ ├── ic_google.imageset │ │ ├── Contents.json │ │ ├── super g.png │ │ ├── super g@2x.png │ │ └── super g@3x.png │ └── ic_twitter.imageset │ │ ├── Contents.json │ │ ├── Twitter_Social_Icon_White.png │ │ ├── Twitter_Social_Icon_White@2x.png │ │ └── Twitter_Social_Icon_White@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── LICENSE ├── README.md ├── Screenshots ├── demo.gif ├── ss1.png └── ss2.png └── Sources └── AZSocialButton.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | 67 | \.DS_Store 68 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.0 -------------------------------------------------------------------------------- /EasySocialButton.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "EasySocialButton" 3 | s.version = "1.0.2" 4 | s.summary = "An easy way to create beautiful social authentication buttons." 5 | s.homepage = "https://github.com/Minitour/EasySocialButton" 6 | s.license = "MIT" 7 | s.author = { "Antonio Zaitoun" => "tony.z.1711@gmail.com" } 8 | s.platform = :ios, "9.0" 9 | s.source = { :git => "https://github.com/Minitour/EasySocialButton.git", :tag => "#{s.version}" } 10 | s.source_files = "Sources/**/*.{swift}" 11 | end 12 | -------------------------------------------------------------------------------- /EasySocialButton.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9D1BF77B1EA238A8004F8F8C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1BF77A1EA238A8004F8F8C /* AppDelegate.swift */; }; 11 | 9D1BF77D1EA238A8004F8F8C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1BF77C1EA238A8004F8F8C /* ViewController.swift */; }; 12 | 9D1BF7801EA238A9004F8F8C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D1BF77E1EA238A8004F8F8C /* Main.storyboard */; }; 13 | 9D1BF7821EA238A9004F8F8C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9D1BF7811EA238A9004F8F8C /* Assets.xcassets */; }; 14 | 9D1BF7851EA238A9004F8F8C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D1BF7831EA238A9004F8F8C /* LaunchScreen.storyboard */; }; 15 | 9D1BF7901EA29385004F8F8C /* AZSocialButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1BF78F1EA29385004F8F8C /* AZSocialButton.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 9D1BF7771EA238A8004F8F8C /* EasySocialButton.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EasySocialButton.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 9D1BF77A1EA238A8004F8F8C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 21 | 9D1BF77C1EA238A8004F8F8C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 22 | 9D1BF77F1EA238A8004F8F8C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | 9D1BF7811EA238A9004F8F8C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 24 | 9D1BF7841EA238A9004F8F8C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 9D1BF7861EA238A9004F8F8C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 26 | 9D1BF78F1EA29385004F8F8C /* AZSocialButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AZSocialButton.swift; path = Sources/AZSocialButton.swift; sourceTree = ""; }; 27 | /* End PBXFileReference section */ 28 | 29 | /* Begin PBXFrameworksBuildPhase section */ 30 | 9D1BF7741EA238A8004F8F8C /* Frameworks */ = { 31 | isa = PBXFrameworksBuildPhase; 32 | buildActionMask = 2147483647; 33 | files = ( 34 | ); 35 | runOnlyForDeploymentPostprocessing = 0; 36 | }; 37 | /* End PBXFrameworksBuildPhase section */ 38 | 39 | /* Begin PBXGroup section */ 40 | 9D1BF76E1EA238A8004F8F8C = { 41 | isa = PBXGroup; 42 | children = ( 43 | 9D1BF78E1EA29376004F8F8C /* Sources */, 44 | 9D1BF7791EA238A8004F8F8C /* EasySocialButton */, 45 | 9D1BF7781EA238A8004F8F8C /* Products */, 46 | ); 47 | sourceTree = ""; 48 | }; 49 | 9D1BF7781EA238A8004F8F8C /* Products */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | 9D1BF7771EA238A8004F8F8C /* EasySocialButton.app */, 53 | ); 54 | name = Products; 55 | sourceTree = ""; 56 | }; 57 | 9D1BF7791EA238A8004F8F8C /* EasySocialButton */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | 9D1BF77A1EA238A8004F8F8C /* AppDelegate.swift */, 61 | 9D1BF77C1EA238A8004F8F8C /* ViewController.swift */, 62 | 9D1BF77E1EA238A8004F8F8C /* Main.storyboard */, 63 | 9D1BF7811EA238A9004F8F8C /* Assets.xcassets */, 64 | 9D1BF7831EA238A9004F8F8C /* LaunchScreen.storyboard */, 65 | 9D1BF7861EA238A9004F8F8C /* Info.plist */, 66 | ); 67 | path = EasySocialButton; 68 | sourceTree = ""; 69 | }; 70 | 9D1BF78E1EA29376004F8F8C /* Sources */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 9D1BF78F1EA29385004F8F8C /* AZSocialButton.swift */, 74 | ); 75 | name = Sources; 76 | sourceTree = ""; 77 | }; 78 | /* End PBXGroup section */ 79 | 80 | /* Begin PBXNativeTarget section */ 81 | 9D1BF7761EA238A8004F8F8C /* EasySocialButton */ = { 82 | isa = PBXNativeTarget; 83 | buildConfigurationList = 9D1BF7891EA238A9004F8F8C /* Build configuration list for PBXNativeTarget "EasySocialButton" */; 84 | buildPhases = ( 85 | 9D1BF7731EA238A8004F8F8C /* Sources */, 86 | 9D1BF7741EA238A8004F8F8C /* Frameworks */, 87 | 9D1BF7751EA238A8004F8F8C /* Resources */, 88 | ); 89 | buildRules = ( 90 | ); 91 | dependencies = ( 92 | ); 93 | name = EasySocialButton; 94 | productName = EasySocialButton; 95 | productReference = 9D1BF7771EA238A8004F8F8C /* EasySocialButton.app */; 96 | productType = "com.apple.product-type.application"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | 9D1BF76F1EA238A8004F8F8C /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | LastSwiftUpdateCheck = 0830; 105 | LastUpgradeCheck = 0830; 106 | ORGANIZATIONNAME = "Antonio Zaitoun"; 107 | TargetAttributes = { 108 | 9D1BF7761EA238A8004F8F8C = { 109 | CreatedOnToolsVersion = 8.3; 110 | DevelopmentTeam = 35DWKWL79J; 111 | ProvisioningStyle = Automatic; 112 | }; 113 | }; 114 | }; 115 | buildConfigurationList = 9D1BF7721EA238A8004F8F8C /* Build configuration list for PBXProject "EasySocialButton" */; 116 | compatibilityVersion = "Xcode 3.2"; 117 | developmentRegion = English; 118 | hasScannedForEncodings = 0; 119 | knownRegions = ( 120 | en, 121 | Base, 122 | ); 123 | mainGroup = 9D1BF76E1EA238A8004F8F8C; 124 | productRefGroup = 9D1BF7781EA238A8004F8F8C /* Products */; 125 | projectDirPath = ""; 126 | projectRoot = ""; 127 | targets = ( 128 | 9D1BF7761EA238A8004F8F8C /* EasySocialButton */, 129 | ); 130 | }; 131 | /* End PBXProject section */ 132 | 133 | /* Begin PBXResourcesBuildPhase section */ 134 | 9D1BF7751EA238A8004F8F8C /* Resources */ = { 135 | isa = PBXResourcesBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | 9D1BF7851EA238A9004F8F8C /* LaunchScreen.storyboard in Resources */, 139 | 9D1BF7821EA238A9004F8F8C /* Assets.xcassets in Resources */, 140 | 9D1BF7801EA238A9004F8F8C /* Main.storyboard in Resources */, 141 | ); 142 | runOnlyForDeploymentPostprocessing = 0; 143 | }; 144 | /* End PBXResourcesBuildPhase section */ 145 | 146 | /* Begin PBXSourcesBuildPhase section */ 147 | 9D1BF7731EA238A8004F8F8C /* Sources */ = { 148 | isa = PBXSourcesBuildPhase; 149 | buildActionMask = 2147483647; 150 | files = ( 151 | 9D1BF77D1EA238A8004F8F8C /* ViewController.swift in Sources */, 152 | 9D1BF7901EA29385004F8F8C /* AZSocialButton.swift in Sources */, 153 | 9D1BF77B1EA238A8004F8F8C /* AppDelegate.swift in Sources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXSourcesBuildPhase section */ 158 | 159 | /* Begin PBXVariantGroup section */ 160 | 9D1BF77E1EA238A8004F8F8C /* Main.storyboard */ = { 161 | isa = PBXVariantGroup; 162 | children = ( 163 | 9D1BF77F1EA238A8004F8F8C /* Base */, 164 | ); 165 | name = Main.storyboard; 166 | sourceTree = ""; 167 | }; 168 | 9D1BF7831EA238A9004F8F8C /* LaunchScreen.storyboard */ = { 169 | isa = PBXVariantGroup; 170 | children = ( 171 | 9D1BF7841EA238A9004F8F8C /* Base */, 172 | ); 173 | name = LaunchScreen.storyboard; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXVariantGroup section */ 177 | 178 | /* Begin XCBuildConfiguration section */ 179 | 9D1BF7871EA238A9004F8F8C /* Debug */ = { 180 | isa = XCBuildConfiguration; 181 | buildSettings = { 182 | ALWAYS_SEARCH_USER_PATHS = NO; 183 | CLANG_ANALYZER_NONNULL = YES; 184 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 185 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 186 | CLANG_CXX_LIBRARY = "libc++"; 187 | CLANG_ENABLE_MODULES = YES; 188 | CLANG_ENABLE_OBJC_ARC = YES; 189 | CLANG_WARN_BOOL_CONVERSION = YES; 190 | CLANG_WARN_CONSTANT_CONVERSION = YES; 191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 192 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 193 | CLANG_WARN_EMPTY_BODY = YES; 194 | CLANG_WARN_ENUM_CONVERSION = YES; 195 | CLANG_WARN_INFINITE_RECURSION = YES; 196 | CLANG_WARN_INT_CONVERSION = YES; 197 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 198 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 199 | CLANG_WARN_UNREACHABLE_CODE = YES; 200 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 201 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 202 | COPY_PHASE_STRIP = NO; 203 | DEBUG_INFORMATION_FORMAT = dwarf; 204 | ENABLE_STRICT_OBJC_MSGSEND = YES; 205 | ENABLE_TESTABILITY = YES; 206 | GCC_C_LANGUAGE_STANDARD = gnu99; 207 | GCC_DYNAMIC_NO_PIC = NO; 208 | GCC_NO_COMMON_BLOCKS = YES; 209 | GCC_OPTIMIZATION_LEVEL = 0; 210 | GCC_PREPROCESSOR_DEFINITIONS = ( 211 | "DEBUG=1", 212 | "$(inherited)", 213 | ); 214 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 215 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 216 | GCC_WARN_UNDECLARED_SELECTOR = YES; 217 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 218 | GCC_WARN_UNUSED_FUNCTION = YES; 219 | GCC_WARN_UNUSED_VARIABLE = YES; 220 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 221 | MTL_ENABLE_DEBUG_INFO = YES; 222 | ONLY_ACTIVE_ARCH = YES; 223 | SDKROOT = iphoneos; 224 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 225 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 226 | }; 227 | name = Debug; 228 | }; 229 | 9D1BF7881EA238A9004F8F8C /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | CLANG_ANALYZER_NONNULL = YES; 234 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 235 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 236 | CLANG_CXX_LIBRARY = "libc++"; 237 | CLANG_ENABLE_MODULES = YES; 238 | CLANG_ENABLE_OBJC_ARC = YES; 239 | CLANG_WARN_BOOL_CONVERSION = YES; 240 | CLANG_WARN_CONSTANT_CONVERSION = YES; 241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 243 | CLANG_WARN_EMPTY_BODY = YES; 244 | CLANG_WARN_ENUM_CONVERSION = YES; 245 | CLANG_WARN_INFINITE_RECURSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 249 | CLANG_WARN_UNREACHABLE_CODE = YES; 250 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 251 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 252 | COPY_PHASE_STRIP = NO; 253 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 254 | ENABLE_NS_ASSERTIONS = NO; 255 | ENABLE_STRICT_OBJC_MSGSEND = YES; 256 | GCC_C_LANGUAGE_STANDARD = gnu99; 257 | GCC_NO_COMMON_BLOCKS = YES; 258 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 259 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 260 | GCC_WARN_UNDECLARED_SELECTOR = YES; 261 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 262 | GCC_WARN_UNUSED_FUNCTION = YES; 263 | GCC_WARN_UNUSED_VARIABLE = YES; 264 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 265 | MTL_ENABLE_DEBUG_INFO = NO; 266 | SDKROOT = iphoneos; 267 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 268 | VALIDATE_PRODUCT = YES; 269 | }; 270 | name = Release; 271 | }; 272 | 9D1BF78A1EA238A9004F8F8C /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 276 | DEVELOPMENT_TEAM = 35DWKWL79J; 277 | INFOPLIST_FILE = EasySocialButton/Info.plist; 278 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 279 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 280 | PRODUCT_BUNDLE_IDENTIFIER = net.crofis.EasySocialButton; 281 | PRODUCT_NAME = "$(TARGET_NAME)"; 282 | SWIFT_VERSION = 4.0; 283 | }; 284 | name = Debug; 285 | }; 286 | 9D1BF78B1EA238A9004F8F8C /* Release */ = { 287 | isa = XCBuildConfiguration; 288 | buildSettings = { 289 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 290 | DEVELOPMENT_TEAM = 35DWKWL79J; 291 | INFOPLIST_FILE = EasySocialButton/Info.plist; 292 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 293 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 294 | PRODUCT_BUNDLE_IDENTIFIER = net.crofis.EasySocialButton; 295 | PRODUCT_NAME = "$(TARGET_NAME)"; 296 | SWIFT_VERSION = 4.0; 297 | }; 298 | name = Release; 299 | }; 300 | /* End XCBuildConfiguration section */ 301 | 302 | /* Begin XCConfigurationList section */ 303 | 9D1BF7721EA238A8004F8F8C /* Build configuration list for PBXProject "EasySocialButton" */ = { 304 | isa = XCConfigurationList; 305 | buildConfigurations = ( 306 | 9D1BF7871EA238A9004F8F8C /* Debug */, 307 | 9D1BF7881EA238A9004F8F8C /* Release */, 308 | ); 309 | defaultConfigurationIsVisible = 0; 310 | defaultConfigurationName = Release; 311 | }; 312 | 9D1BF7891EA238A9004F8F8C /* Build configuration list for PBXNativeTarget "EasySocialButton" */ = { 313 | isa = XCConfigurationList; 314 | buildConfigurations = ( 315 | 9D1BF78A1EA238A9004F8F8C /* Debug */, 316 | 9D1BF78B1EA238A9004F8F8C /* Release */, 317 | ); 318 | defaultConfigurationIsVisible = 0; 319 | defaultConfigurationName = Release; 320 | }; 321 | /* End XCConfigurationList section */ 322 | }; 323 | rootObject = 9D1BF76F1EA238A8004F8F8C /* Project object */; 324 | } 325 | -------------------------------------------------------------------------------- /EasySocialButton.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /EasySocialButton/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/.DS_Store -------------------------------------------------------------------------------- /EasySocialButton/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // EasySocialButton 4 | // 5 | // Created by Antonio Zaitoun on 15/04/2017. 6 | // Copyright © 2017 Antonio Zaitoun. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. 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 active 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 | -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/background.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "background.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/background.imageset/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/background.imageset/background.jpg -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_facebook.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "FB-f-Logo__white_72.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "FB-f-Logo__white_72@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "FB-f-Logo__white_72@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_facebook.imageset/FB-f-Logo__white_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_facebook.imageset/FB-f-Logo__white_72.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_facebook.imageset/FB-f-Logo__white_72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_facebook.imageset/FB-f-Logo__white_72@2x.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_facebook.imageset/FB-f-Logo__white_72@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_facebook.imageset/FB-f-Logo__white_72@3x.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_google.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "super g.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "super g@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "super g@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_google.imageset/super g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_google.imageset/super g.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_google.imageset/super g@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_google.imageset/super g@2x.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_google.imageset/super g@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_google.imageset/super g@3x.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_twitter.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Twitter_Social_Icon_White.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Twitter_Social_Icon_White@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "Twitter_Social_Icon_White@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_twitter.imageset/Twitter_Social_Icon_White.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_twitter.imageset/Twitter_Social_Icon_White.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_twitter.imageset/Twitter_Social_Icon_White@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_twitter.imageset/Twitter_Social_Icon_White@2x.png -------------------------------------------------------------------------------- /EasySocialButton/Assets.xcassets/ic_twitter.imageset/Twitter_Social_Icon_White@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/EasySocialButton/Assets.xcassets/ic_twitter.imageset/Twitter_Social_Icon_White@3x.png -------------------------------------------------------------------------------- /EasySocialButton/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /EasySocialButton/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 144 | 172 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | -------------------------------------------------------------------------------- /EasySocialButton/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarStyle 32 | UIStatusBarStyleLightContent 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /EasySocialButton/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // EasySocialButton 4 | // 5 | // Created by Antonio Zaitoun on 15/04/2017. 6 | // Copyright © 2017 Antonio Zaitoun. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var googleButton: AZSocialButton! 14 | 15 | @IBOutlet weak var facebookButton: AZSocialButton! 16 | 17 | @IBOutlet weak var twitterButton: AZSocialButton! 18 | 19 | @IBOutlet weak var loginButton: UIButton! 20 | 21 | override func viewDidLoad() { 22 | super.viewDidLoad() 23 | 24 | 25 | 26 | loginButton.layer.cornerRadius = 5 27 | loginButton.layer.masksToBounds = true 28 | 29 | googleButton.onClickAction = { (button) in 30 | print("google") 31 | } 32 | 33 | facebookButton.onClickAction = { (button) in 34 | print("facebook") 35 | } 36 | 37 | twitterButton.onClickAction = { (button) in 38 | print("twitter") 39 | } 40 | } 41 | 42 | 43 | override var preferredStatusBarStyle: UIStatusBarStyle{ 44 | return .lightContent 45 | } 46 | 47 | override func didReceiveMemoryWarning() { 48 | super.didReceiveMemoryWarning() 49 | // Dispose of any resources that can be recreated. 50 | } 51 | 52 | 53 | } 54 | 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Antonio Zaitoun 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EasySocialButton 2 | An easy way to create beautiful social authentication buttons 3 | 4 | ## Screenshots 5 | 6 | 7 | 8 | 9 | 10 | 11 | ## Installation 12 | 13 | ### Cocoa Pods 14 | 15 | ```bash 16 | pod 'EasySocialButton' 17 | ``` 18 | 19 | ### Manual 20 | 21 | Drag and drop ```AZSocialButton.swift``` to your project. 22 | 23 | ## Usage 24 | 25 | ### Interface Builder 26 | 27 | Simply add a UIButton, and in the Identity Inspector change the class to `AZSocialButton`. 28 | 29 | ### Programmatically 30 | 31 | ```swift 32 | let socialButton = AZSocialButton(frame: CGRect(x: 20, y: 20, width: 200, height: 40)) 33 | 34 | socialButton.animateInteraction = true 35 | socialButton.useCornerRadius = true 36 | socialButton.cornerRadius = 5 37 | socialButton.highlightOnTouch = false 38 | socialButton.image = #imageLiteral(resourceName: "ic_google") 39 | socialButton.setTitle("Sign in with Google", for: []) 40 | socialButton.setTitleColor(.black, for: []) 41 | socialButton.titleLabel?.font = UIFont.systemFont(ofSize: 15) 42 | 43 | socialButton.onClickAction = { (button) in 44 | print("do social login stuff") 45 | } 46 | 47 | view.addSubview(socialButton) 48 | ``` 49 | -------------------------------------------------------------------------------- /Screenshots/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/Screenshots/demo.gif -------------------------------------------------------------------------------- /Screenshots/ss1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/Screenshots/ss1.png -------------------------------------------------------------------------------- /Screenshots/ss2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Minitour/EasySocialButton/5589ff587ddfc29ef87fad57f941ac3308aa5e69/Screenshots/ss2.png -------------------------------------------------------------------------------- /Sources/AZSocialButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MZButton.swift 3 | // Moodz UIViewSubclass 4 | // 5 | // Created by Antonio Zaitoun on 20/02/2017. 6 | // Copyright © 2017 Antonio Zaitoun. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @IBDesignable 12 | open class AZSocialButton: UIButton{ 13 | 14 | /// The image view which holds the icon. 15 | fileprivate var imageHolder: UIImageView! 16 | 17 | /// Start animation duration. 18 | open var beginAnimationDuration: Double = 0.2 19 | 20 | /// End animation duration. 21 | open var endAnimationDuration: Double = 0.25 22 | 23 | /// Animation Spring velocity. 24 | open var initialSpringVelocity: Float = 6.0 25 | 26 | /// Animation Spring Damping. 27 | open var usingSpringWithDamping: Float = 0.2 28 | 29 | /// A flag which indicates if the button is in the middle of an animation. 30 | internal (set) open var isAnimating = false 31 | 32 | /// Social Icon 33 | @IBInspectable 34 | open var image: UIImage?{ 35 | didSet{ 36 | imageHolder?.image = image 37 | } 38 | } 39 | 40 | /// Should interaction be animated. 41 | @IBInspectable 42 | open var animateInteraction: Bool = false 43 | 44 | /// Should highlight on interaction. 45 | @IBInspectable 46 | open var highlightOnTouch: Bool = true 47 | 48 | /// Animation Scale. 49 | open var animationScale: CGFloat = 0.95 50 | 51 | /// Corner radius. 52 | @IBInspectable 53 | open var cornerRadius: CGFloat = 2 { 54 | didSet{ 55 | layer.cornerRadius = useCornerRadius ? cornerRadius : bounds.midY 56 | } 57 | } 58 | 59 | ///Use given corner radius. if set to false will use the bounds.height / 2 60 | @IBInspectable 61 | open var useCornerRadius: Bool = false { 62 | didSet{ 63 | layer.cornerRadius = useCornerRadius ? cornerRadius : bounds.midY 64 | } 65 | } 66 | 67 | ///The primary color of the button. 68 | @IBInspectable 69 | open var color: UIColor = .white{ 70 | didSet{ 71 | layer.backgroundColor = color.cgColor 72 | } 73 | } 74 | 75 | /// Shadow Opacity of the button 76 | @IBInspectable 77 | open var shadowOpacity: Float = 0.2{ 78 | didSet{ 79 | layer.shadowOpacity = shadowOpacity 80 | } 81 | } 82 | 83 | /// Shadow radius of the button. 84 | @IBInspectable 85 | open var shadowRadius: CGFloat = 1.0{ 86 | didSet{ 87 | layer.shadowRadius = shadowRadius 88 | } 89 | } 90 | 91 | ///The function that is triggered once button is clicked (if set) 92 | open var onClickAction: ((AZSocialButton)->Void)? 93 | 94 | /// Padding between the image and the button. 95 | open var padding: CGFloat { 96 | return 7.0 97 | } 98 | 99 | /// The imageview. 100 | final override public var imageView: UIImageView?{ 101 | return imageHolder 102 | } 103 | 104 | /// Init with frame. 105 | /// 106 | /// - Parameter frame: The frame of the button. 107 | override init(frame: CGRect) { 108 | super.init(frame: frame) 109 | setup() 110 | } 111 | 112 | /// Init with coder 113 | /// 114 | /// - Parameter coder: NIB Coder 115 | required public init?(coder aDecoder: NSCoder) { 116 | super.init(coder: aDecoder) 117 | setup() 118 | } 119 | 120 | /// Setup function called from initializers. 121 | internal func setup(){ 122 | addTarget(self, action: #selector(click), for: .touchUpInside) 123 | isExclusiveTouch = true 124 | imageHolder = UIImageView() 125 | imageHolder.contentMode = .scaleAspectFit 126 | addSubview(imageHolder) 127 | contentHorizontalAlignment = .left 128 | imageHolder.translatesAutoresizingMaskIntoConstraints = false 129 | imageHolder.leftAnchor.constraint(equalTo: leftAnchor, constant: padding * 2).isActive = true 130 | imageHolder.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true 131 | imageHolder.heightAnchor.constraint(equalTo: heightAnchor, multiplier: 0.4).isActive = true 132 | imageHolder.widthAnchor.constraint(equalTo: imageHolder.heightAnchor, multiplier: 1.0).isActive = true 133 | } 134 | 135 | /// Called when adding the view. 136 | override open func didMoveToSuperview() { 137 | contentEdgeInsets = UIEdgeInsets(top: 0, left: frame.height * 0.4 + padding * 4, bottom: 0, right: 0) 138 | layer.backgroundColor = color.cgColor 139 | if !isAnimating { 140 | layer.cornerRadius = useCornerRadius ? cornerRadius : bounds.midY 141 | } 142 | imageHolder?.image = image 143 | layer.shadowOffset = CGSize(width: 0.5, height: 0.5) 144 | layer.shadowOpacity = shadowOpacity 145 | layer.shadowRadius = shadowRadius 146 | } 147 | 148 | /// Selector function 149 | @objc func click(){ 150 | onClickAction?(self) 151 | } 152 | 153 | open override var isHighlighted: Bool{ 154 | set{ 155 | if highlightOnTouch { 156 | self.alpha = newValue ? 0.5 : 1 157 | } 158 | super.isHighlighted = newValue 159 | } 160 | get{ 161 | return super.isHighlighted 162 | } 163 | } 164 | 165 | 166 | } 167 | 168 | extension AZSocialButton{ 169 | 170 | override open func touchesBegan(_ touches: Set, with event: UIEvent?) { 171 | if self.animateInteraction{ 172 | isAnimating = true 173 | UIView.animate(withDuration: self.beginAnimationDuration, animations: { 174 | self.transform = CGAffineTransform(scaleX: self.animationScale, y: self.animationScale) 175 | }) { (complete) in 176 | self.isAnimating = false 177 | } 178 | } 179 | super.touchesBegan(touches, with: event) 180 | } 181 | 182 | override open func touchesMoved(_ touches: Set, with event: UIEvent?) { 183 | let tap:UITouch = touches.first! 184 | let point = tap.location(in: self) 185 | if !self.bounds.contains(point){ 186 | if self.animateInteraction{ 187 | isAnimating = true 188 | UIView.animate(withDuration: self.beginAnimationDuration, animations: { 189 | self.transform = .identity 190 | }) { (complete) in 191 | self.isAnimating = false 192 | } 193 | } 194 | }else{ 195 | if self.animateInteraction{ 196 | isAnimating = true 197 | UIView.animate(withDuration: self.beginAnimationDuration, animations: { 198 | self.transform = CGAffineTransform(scaleX: self.animationScale, y: self.animationScale) 199 | }) { (complete) in 200 | self.isAnimating = false 201 | } 202 | } 203 | } 204 | super.touchesMoved(touches, with: event) 205 | 206 | } 207 | 208 | override open func touchesEnded(_ touches: Set, with event: UIEvent?) { 209 | if self.animateInteraction{ 210 | isAnimating = true 211 | UIView.animate(withDuration: self.endAnimationDuration, 212 | delay: 0, 213 | usingSpringWithDamping: CGFloat(self.usingSpringWithDamping), 214 | initialSpringVelocity: CGFloat(self.initialSpringVelocity), 215 | options: .allowUserInteraction, 216 | animations: { 217 | self.transform = .identity 218 | }) { (complete) in 219 | self.isAnimating = false 220 | } 221 | } 222 | super.touchesEnded(touches, with: event) 223 | 224 | } 225 | 226 | override open func touchesCancelled(_ touches: Set, with event: UIEvent?) { 227 | if self.animateInteraction{ 228 | isAnimating = true 229 | UIView.animate(withDuration: self.endAnimationDuration, 230 | delay: 0, 231 | usingSpringWithDamping: CGFloat(self.usingSpringWithDamping), 232 | initialSpringVelocity: CGFloat(self.initialSpringVelocity), 233 | options: .allowUserInteraction, 234 | animations: { 235 | self.transform = .identity 236 | }) { (complete) in 237 | self.isAnimating = false 238 | } 239 | } 240 | super.touchesCancelled(touches, with: event) 241 | } 242 | } 243 | --------------------------------------------------------------------------------