我正在使用动画师来实现动画,比如
[[self.view animator] setFrame:newFrame];
Run Code Online (Sandbox Code Playgroud)
但是我希望在动画完成后运行一个方法或块,如下所示:
[[self.view animator] setFrame:newFrame onComplete:^{
NSLog(@"****");
}];
Run Code Online (Sandbox Code Playgroud)
有没有办法实现它?
Dmi*_*try 13
你应该使用NSAnimationContext它是completionHandler:
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setCompletionHandler:^{
NSLog(@"****");
}];
[[self.view animator] setFrame:newFrame];
[NSAnimationContext endGrouping];
Run Code Online (Sandbox Code Playgroud)