Adding UIView on top of all views dynamically during runtime?
Posted
by
Easwaramoorthy Kanagaraj
on Stack Overflow
See other posts from Stack Overflow
or by Easwaramoorthy Kanagaraj
Published on 2013-06-29T07:23:05Z
Indexed on
2013/06/29
10:21 UTC
Read the original article
Hit count: 165
Team,
I am trying to bring a menu in top of all visible views during runtime. This menu should be easily addable and removable dynamically in certain conditions.
To do this, I have tried adding a button view to the UIWindow as a subview during runtime.
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:nil forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[window addSubview:button];
[window makeKeyAndVisible];
[window bringSubviewToFront:button];
But it doesnt worked. Also I have tried to place this button in the root view controller, but no luck again.
Edit - Note: This code is not from a UIViewController
. I am trying to build a library this will be in that library code. Use case be like you could post NSNotification to enable and disable this menu dynamically during runtime.
Please suggest.
Thanks !
© Stack Overflow or respective owner