본문 바로가기
프로그래밍 놀이터/iOS

[ios/reference] Advanced Animation Tricks

by 돼지왕 왕돼지 2017. 11. 29.
반응형

[ios/reference] Advanced Animation Tricks


https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html

advanced animation, animation pause, animation speed, camediatiming, cftimeinterval, converttime, non zero, pauselayer, protocol, resumelayer, timeoffset, [ios/reference] Advanced Animation Tricks


-

Animation pause 를 위해서는 CAMediaTiming  protocol 을 layer 에 전달하고, layer 의 animation speed 를 0.0 으로 설정하면 된다.

이 speed 값이 non zero 값이 될 때까지 animation 은 pause 된다.


ex)

-(void)pauseLayer:(CALayer*)layer{

     CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];

     layer.speed = 0.0;

     layer.timeOffset = pausedTime;


-(void)resumeLayer:(CALayer*)layer{

     CFTimeInterval pausedTime = [layer timeOffset];

     layer.speed = 1.0;

     layer.timeOffset = 0.0;

     layer.beginTime = 0.0;

     CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;

     layer.beginTime = timeSincePause;

}





반응형

댓글