간단하게 Animation
관련 공식문서를 읽고, 이에 대해 정리한 것을 기록합니다.
animate(withDuration:delay:options:animations:completion:)
Animate changes to one or more views using the specified duration, delay, options, and completion handler.
지정된 duration
, delay
와 completion Handler
를 사용해서 views
의 변경을 Animate
한다 라고 되어있습니다.
class func animate(
withDuration duration: TimeInterval,
delay: TimeInterval,
options: UIView.AnimationOptions = [],
animations: @escaping () -> Void,
completion: ((Bool) -> Void)? = nil
)
먼저 선언부를 보면 위의 Class Method
로 정의되어 있는 것을 확인 할 수 있습니다.
각각 Parameter
들에 대해 알아봅시다.
먼저 한가지 알아 두고 가야 할 것은 animate
함수의 paremeters
의 시간에 대한 단위는 second(초)
입니다.
The total duration of the animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them.
애니메이션의 총 지속 시간(초 단위)에 대한 것을 말합니다.
만약 파라미터 값으로 0이나 음수 값을 지정하게 되면 애니메이션으로 적용되지 않습니다.
The amount of time (measured in seconds) to wait before beginning the animations. Specify a value of 0 to begin the animations immediately.
애니메이션을 시작하기 전에 기다리는 시간에 대해 말합니다.
즉시 시작하기 위해서는 값으로 0을 넣으면 됩니다.
A mask of options indicating how you want to perform the animations. For a list of valid constants, see UIView.AnimationOptions.
애니메이션 동작을 수행하는 방법을 나타내는 옵션에 대한 Mask
입니다.
유효한 값들에 대한 리스트는 UIView
의 AnimationOptions
를 참고 합니다.
이곳에서 확인 할 수 있습니다!
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.
뷰에 커밋할 변경 사항에 대한 내용을 포함하는 block object
입니다.
뷰 계층 구조에서 뷰의 애니메이션 가능한 속성들을 프로그래밍 방식으로 변경이 가능하게 됩니다.
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.
애니메이션 시퀀스가 끝날 때 실행하는 block object
입니다.
이 클로저에서는 반환값이 없고 애니메이션이 completion Handler
가 호출되기 전에 실제로 완료 되었는지에 대한 여부를 나타내는 단일 Boolean
상수를 사용합니다.
애니메이션 지속시간이 0일 경우 이 클로저는 다음 run loop cycle
이 시작 될 때 수행됩니다.
이 매개 변수는 NULLABLE
합니다.
This method initiates a set of animations to perform on the view. The block object in the animations parameter contains the code for animating the properties of one or more views.
During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.) If you want users to be able to interact with the views, include the allowUserInteraction constant in the options parameter.
animate
메소드는 Type Method
고 선언은 Class Method
로 선언 되어있다.parameter
로 들어오는 duration
, delay
, options
, animations
, completion
을 통해 여러가지 옵션사항들을 줄 수 있다.Block Object
라고 나오는 것들은 맥락상 Closure
블록들을 말하는 것 같다.