ios개발/개념 정리

<스위프트> 에니메이션 animate

studying develop 2020. 3. 8. 22:27

[https://developer.apple.com/documentation/uikit/uiview/1622451-animate]

 

class func animate(withDuration duration: TimeInterval, 
             delay: TimeInterval, 
           options: UIView.AnimationOptions = [], 
        animations: @escaping () -> Void, 
        completion: ((Bool) -> Void)? = nil)

Parameters

duration

The total duration of the animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them.

 

초 단위로 에니메이션이 실행되는 시간이다.

 

delay

The amount of time (measured in seconds) to wait before beginning the animations. Specify a value of 0 to begin the animations immediately.

 

에니메이션 시작전 딜레이 시간,

 

options

A mask of options indicating how you want to perform the animations. For a list of valid constants, see UIView.AnimationOptions..

 

에니메이션이 수행되는 옵션

 

animations

A block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be NULL.

 

뷰에 변화를 주는 블록 객체다.

 

completion

A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.

 

에니메이션이 종료된 후의 블록 객체.

 

 

    private func showOutlineAnimation(){
        UIView.animate(withDuration: 3, delay: 0.3, options: [], animations: {
            [unowned self] in
            
            self.outlineAppMarkV.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
            
            }, completion: { [unowned self] (_) in
                self.showLocationButton()
        })
    }

 

animation에 성공했다. 그런데 다른 개념중에 UIView.animateKeyFrame 이라는게 있는데, 이건 내가 찾아봐서 알기로는 에니메이션을 순차적으로 계속 보여줄때 사용한다는듯? animate로는 코드 블록이 복잡해 지니까? 

 

[https://jinnify.tistory.com/67] 여기 자세히 나와있다.