chaneeii / iOS-Study-Log

✨ iOS에 대해 공부한 것들을 기록합니다 ✨
18 stars 0 forks source link

✨ UIButton 효과 #29

Open chaneeii opened 2 years ago

chaneeii commented 2 years ago

살짝 작았다가 커지는 효과

public extension UIView {
    func showAnimation(_ completionBlock: @escaping () -> Void) {
      isUserInteractionEnabled = false 
        UIView.animate(withDuration: 0.1, 
                       delay: 0, 
                       options: .curveLinear, 
                       animations: { [weak self] in
                            self?.transform = CGAffineTransform.init(scaleX: 0.95, y: 0.95)
        }) {  (done) in
            UIView.animate(withDuration: 0.1, 
                           delay: 0, 
                           options: .curveLinear, 
                           animations: { [weak self] in
                                self?.transform = CGAffineTransform.init(scaleX: 1, y: 1)
            }) { [weak self] (_) in
                self?.isUserInteractionEnabled = true
                completionBlock()
            }
        }
    }
}

색이 약간 회색톤으로 fade in 되는 효과