我在屏幕上有一个包含几个标签的UIView。我试图进行翻转视图的转换,一旦我在动画的一半,我希望能够更新标签。我怎样才能做到这一点?
[UIView transitionWithView:self.myView
duration:.7
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
// It doesn't update the labels here, until I scoll the tableview (containing the view)
//[self.myView update];
}
completion:^(BOOL finished){
// It doesn't look nice here because it doesn't look smooth, the label flashes and changes after the animation is complete
//[self.myView update];
}];
答案 0 :(得分:4)
问题是我启用了shouldRasterize,这不允许在动画制作期间更新内容。解决方案是在动画完成之前关闭光栅化,并在动画完成后重新打开它。
我没有摆脱光栅化的原因是视图在tableView中,并且在滚动tableView时光栅化仍然有用。
self.layer.shouldRasterize = NO;
[UIView transitionWithView:self
duration:animationDuration
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{/*update the content here, I did it outside of the transition method though*/}
completion:^(BOOL finished){
if (finished)
{
self.layer.shouldRasterize = YES;
}
}];