ios - Present UIView over darkened UIWindow -
i trying present uiview while @ same time darkening rest of screen. however, having difficulty. code:
uiwindow *window = [[uiapplication sharedapplication] keywindow]; self.viewtodarken = [[uiview alloc] initwithframe:cgrectmake(0, 0, 320, 568)]; [self.viewtodarken setbackgroundcolor:[uicolor blackcolor]]; [self.viewtodarken setalpha:0.0f]; [window insertsubview:self.viewtodarken abovesubview:self.hostview]; [self.hostview addsubview:self]; [uiview animatewithduration:0.25f delay:0.0 options:uiviewanimationcurvelinear animations:^(void) { [self setframe:[self destinationframe]]; if (self.viewtodarken) self.viewtodarken.alpha = 0.7f; }completion:^(bool finished) { [self notifydidshow]; }];
however, can't view darken placed below view adding (self). ideas why doesn't work?
thanks!
you adding viewtodarken
above self.hostview
adding self
hostview
of course self below viewtodarken
. need add viewtodarken
below self.hostview
.
what have is:
hostview + self(view) (below) -> viewtodarken
you need
viewtodarken (below)-> hostview + self(view)
you should have:
[window insertsubview:self.viewtodarken belowsubview:self.hostview];
Comments
Post a Comment