Notice
Recent Posts
Recent Comments
Link
관리 메뉴

김종권의 iOS 앱 개발 알아가기

[iOS - swift] 포커스 애니메이션 본문

iOS 응용 (swift)

[iOS - swift] 포커스 애니메이션

jake-kim 2021. 1. 10. 17:07

화면을 탭 할 경우 초점 애니메이션

  • UIImageView라는 임의의 뷰를 생성하여 애니메이션이 시작 시 addSubviews 후 끝날 때 removeFromSuperview()
extension UIView {
  func focusAnimationAt(_ point: CGPoint) {
          let focusView = UIImageView(image: UIImage(systemName: “포커스 사진 이름“))
          focusView.center = point
          focusView.alpha = 0.0
          view.addSubview(focusView)

          UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, animations: {
              focusView.alpha = 1.0
              focusView.transform = CGAffineTransform(scaleX: 1.25, y: 1.25)
          }) { (success) in
              UIView.animate(withDuration: 0.15, delay: 0.5, options: .curveEaseInOut, animations: {
                  focusView.alpha = 0.0
                  focusView.transform = CGAffineTransform(translationX: 0.6, y: 0.6)
              }) { (success) in
                  focusView.removeFromSuperview()
            }
        }
    }
}

 

Comments