IOS:使用模态 ViewController 进行转换

IOS: Transition with modal ViewContorller

我有创建为 VC 的自定义操作 sheet。我用 'overCurrentContex' 和代码

呈现它
[self presentViewContoller:myVC animated:YES completion:nil];

我需要给它添加深色背景。 我用代码

添加了它
self.view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];

但是当我以模态方式呈现它时,它从底部滑出,背景颜色为深色。 我需要这种颜色看起来像 Fade。

我该怎么做?我需要为其添加自定义过渡吗?

据我了解,您想让 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
                 }];