diff --git a/Classes/ZFRippleButton.swift b/Classes/ZFRippleButton.swift index 33adcfa..ac86d7a 100755 --- a/Classes/ZFRippleButton.swift +++ b/Classes/ZFRippleButton.swift @@ -108,16 +108,16 @@ open class ZFRippleButton: UIButton { touchCenterLocation = nil } - UIView.animate(withDuration: 0.1, delay: 0, options: UIViewAnimationOptions.allowUserInteraction, animations: { - self.rippleBackgroundView.alpha = 1 + UIView.animate(withDuration: 0.1, delay: 0, options: .allowUserInteraction, animations: { [weak self] in + self?.rippleBackgroundView.alpha = 1 }, completion: nil) rippleView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) - UIView.animate(withDuration: 0.7, delay: 0, options: [UIViewAnimationOptions.curveEaseOut, UIViewAnimationOptions.allowUserInteraction], - animations: { - self.rippleView.transform = CGAffineTransform.identity + UIView.animate(withDuration: 0.7, delay: 0, options: [.curveEaseOut, .allowUserInteraction], + animations: { [weak self] in + self?.rippleView.transform = CGAffineTransform.identity }, completion: nil) if shadowRippleEnable { @@ -132,7 +132,7 @@ open class ZFRippleButton: UIButton { let groupAnim = CAAnimationGroup() groupAnim.duration = 0.7 - groupAnim.fillMode = kCAFillModeForwards + groupAnim.fillMode = .forwards groupAnim.isRemovedOnCompletion = false groupAnim.animations = [shadowAnim, opacityAnim] @@ -152,33 +152,33 @@ open class ZFRippleButton: UIButton { } fileprivate func animateToNormal() { - UIView.animate(withDuration: 0.1, delay: 0, options: UIViewAnimationOptions.allowUserInteraction, animations: { - self.rippleBackgroundView.alpha = 1 + UIView.animate(withDuration: 0.1, delay: 0, options: .allowUserInteraction, animations: { [weak self] in + self?.rippleBackgroundView.alpha = 1 }, completion: {(success: Bool) -> () in - UIView.animate(withDuration: self.touchUpAnimationTime, delay: 0, options: UIViewAnimationOptions.allowUserInteraction, animations: { - self.rippleBackgroundView.alpha = 0 + UIView.animate(withDuration: self.touchUpAnimationTime, delay: 0, options: .allowUserInteraction, animations: { [weak self] in + self?.rippleBackgroundView.alpha = 0 }, completion: nil) }) UIView.animate(withDuration: 0.7, delay: 0, options: [.curveEaseOut, .beginFromCurrentState, .allowUserInteraction], - animations: { - self.rippleView.transform = CGAffineTransform.identity + animations: { [weak self, tempShadowRadius, tempShadowOpacity] in + self?.rippleView.transform = CGAffineTransform.identity let shadowAnim = CABasicAnimation(keyPath:"shadowRadius") - shadowAnim.toValue = self.tempShadowRadius + shadowAnim.toValue = tempShadowRadius let opacityAnim = CABasicAnimation(keyPath:"shadowOpacity") - opacityAnim.toValue = self.tempShadowOpacity + opacityAnim.toValue = tempShadowOpacity let groupAnim = CAAnimationGroup() groupAnim.duration = 0.7 - groupAnim.fillMode = kCAFillModeForwards + groupAnim.fillMode = .forwards groupAnim.isRemovedOnCompletion = false groupAnim.animations = [shadowAnim, opacityAnim] - self.layer.add(groupAnim, forKey:"shadowBack") + self?.layer.add(groupAnim, forKey:"shadowBack") }, completion: nil) } diff --git a/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo.xcodeproj/project.pbxproj b/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo.xcodeproj/project.pbxproj index a842232..dbc68cb 100755 --- a/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo.xcodeproj/project.pbxproj +++ b/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo.xcodeproj/project.pbxproj @@ -352,11 +352,12 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ZFRippleButtonDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -364,11 +365,12 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ZFRippleButtonDemo/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo/AppDelegate.swift b/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo/AppDelegate.swift index 7bd6405..c6777ec 100755 --- a/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo/AppDelegate.swift +++ b/Demo/ZFRippleButtonDemo/ZFRippleButtonDemo/AppDelegate.swift @@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true }