Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWindow animation

Tags:

iphone

ipad

ios4

I currently use a custom UIWindow to display a custom alert view to make it look Apple style. When I remove it, it doesn't fade automatically, sk I decided to use a UIView animation and change the alpha to 0 then remove it but that still didn't do the trick. Would you guys know what to do?

like image 494
G33kz0r Avatar asked Aug 25 '10 08:08

G33kz0r


1 Answers

For the faded background window used by my own custom AlertView class (similar to what it sounds like you are doing) I made a custom UIWindow and overrode makeKeyAndVisible, but you can also do this outside context of the class:

- (void)makeKeyAndVisible
{
    self.backgroundColor = [UIColor clearColor];
    self.alpha = 0;

    [UIView beginAnimations: @"fade-in" context: nil];

    [super makeKeyAndVisible];

    self.alpha = 1;

    [UIView commitAnimations];
}

- (void)resignKeyWindow
{
    self.alpha = 1;

    [UIView beginAnimations: @"fade-out" context: nil];

    [super resignKeyWindow];

    self.alpha = 0;

    [UIView commitAnimations];
}
like image 63
TomSwift Avatar answered Oct 13 '22 20:10

TomSwift