更改UIViewAnimationOptionTransitionFlipFromLeft的过渡色调/淡化颜色

时间:2015-08-13 18:19:33

标签: ios objective-c uiview uiviewanimationtransition

我正在我的程序中使用UIViewAnimationOptionTransitionFlipFromLeft在两个容器视图之间切换:

[UIView transitionWithView:self.view
                          duration:1.0
                           options:UIViewAnimationOptionTransitionFlipFromLeft
                        animations:^{
                            self.timerPage.hidden   = true;
                            self.countdownPage.hidden = false;
                        } completion:nil
         ];

它运作正常,但是我的错误是我的视图淡入淡出黑色,我希望颜色变为白色。我搜索了各种线程,但我找不到解决这个确切问题的方法。

我无法上传图片,但此问题中的图片正好显示了我正在谈论的内容。过渡期间视图会变为黑色:UIView transitionFromView: how can I do black background during transition?

1 个答案:

答案 0 :(得分:0)

您可以通过向视图添加子视图或子图层以及明确的背景颜色,然后在动画块中将其背景颜色设置为白色来获得所需的行为。

UIView *whiteView = [[UIView alloc] init];
whiteView.frame = self.button.bounds;
[self.button addSubview:whiteView];

[UIView animateWithDuration:0.45 animations:^{
    whiteView.backgroundColor = [UIColor whiteColor];
}];