【问题标题】:IOS: Transition with modal ViewContorllerIOS:使用模态 ViewController 进行转换
【发布时间】:2015-06-10 22:14:49
【问题描述】:
我有作为 VC 创建的自定义操作表。我用“overCurrentContex”和代码展示它
[self presentViewContoller:myVC animated:YES completion:nil];
我需要为其添加深色背景。
我用代码添加了它
self.view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
但当我以模态方式呈现它时,它会从底部以我的深色背景颜色滑动。
我需要这种颜色看起来像 Fade。
我该怎么做?我需要添加自定义过渡吗?
【问题讨论】:
标签:
ios
uiviewcontroller
transition
modalviewcontroller
transitions
【解决方案1】:
据我了解,您希望 ViewController 从底部向上滑动,然后将背景颜色更改(过渡)为您选择的较暗颜色?
我可能会使用背景的 alpha 值并对其进行动画处理以使其变得更加不透明以实现该效果。
这是一个使用动画块的 alpha 值的可能动画:
self.view.alpha = 0.0f;
float alphaValue = 1.0f;
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) {
//The stuff you want to animate
self.view.alpha = alphaValue;
}
completion:^(BOOL finished){
//anything you want to do right after the animation is done
}];