IOS: Transition with modal ViewContorller

105 views Asked by At

I have custom action sheet that I create as VC. I present it with 'overCurrentContex' with the code

[self presentViewContoller:myVC animated:YES completion:nil];

I need to add dark background to it. I added it with code

self.view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];

But as I present it modally it slides from the bottom with my dark backgroundColor. I need that this color appears like Fade.

How can I do it? I need to add custom transition to it?

1

There are 1 answers

0
Ethan Parker On BEST ANSWER

As I understand it, you're wanting to have the ViewController slide up from the bottom then have the background color change (transition) to a darker color of your choice?

I'd probably use the alpha value of the background and animate it to become more opaque to achieve that effect.

Here's a possible animation of the alpha value using an animation block:

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