4

我在屏幕上有一个 UIView 包含一些标签。我正在尝试进行翻转视图的转换,并且一旦我完成 nimation 的一半,我希望能够更新标签。我怎样才能做到这一点?

[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];
                        }];
4

1 回答 1

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;
                }
            }];
于 2012-11-19T21:36:08.533 回答