我正在使用transitionWithView动画块来动画视图。当用户向左或向右滑动视图时,将调用此块。它工作得很好。但是我想创建我自己的自定义动画,就像视图从左向右改变一样。我不知道如何做到这一点。在UIViewAnimationOptions中,我使用UIViewAnimationOptionTransitionCurlUp进行从右向左的滑动,使用UIViewAnimationOptionTransitionCurlDown进行从左向右的滑动。
[UIView transitionWithView:self.view duration:0.6 options:UIViewAnimationOptionTransitionCurlUp animations:^{
setDataInLayout();
} completion:^(BOOL finished) {
[scrollViewContent setContentOffset:CGPointZero animated:YES];
[self.delegate updatePaginationCounter:_currentStoneIndex];
}];发布于 2015-11-19 20:15:24
你必须自己实现这个动画。我会使用UIView动画API,如下所示:
UIView.animateWithDuration(0.6, animations: {
// apply 2D transformation to the view, or use any other animatable property
self.view.transform = CGAffineTransformMakeRotation(fullRotation)
} completion: {finished in
// you completion block
})这是UIView的动画属性的list。对于更复杂的动画,可以使用基于关键帧的动画:
UIView.animateKeyframesWithDuration(duration, delay: delay, options: options, animations: {
// add your keyframe animations here
UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 1/2, animations: {
self.view.transform = ...
})
UIView.addKeyframeWithRelativeStartTime(1/3, relativeDuration: 1/2, animations: {
self.view.transform = ...
})
}, completion: {finished in
// completion block
})
}https://stackoverflow.com/questions/33802102
复制相似问题