繁体   English   中英

iOS - 在动画过渡期间更新标签?

[英]iOS - Updating label during animation transition?

我在屏幕上有一个包含几个标签的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];
                        }];

问题是我启用了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;
                }
            }];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM