How to add UIview over a ViewController and its NavigationController
Posted
by
Roxee Man
on Stack Overflow
See other posts from Stack Overflow
or by Roxee Man
Published on 2013-10-31T16:29:24Z
Indexed on
2013/10/31
21:55 UTC
Read the original article
Hit count: 251
I have a ViewController
with a NavigationController
and I want to add a translucent UIView
with some Buttons over the ViewController
when I press a ViewController button, the problem is that I can not put the UIView
over the NavigationBar
. How can I solve this?
This is my code ( Very simple)
-(void)setOpacityView
{
opacityVw = [[UIView alloc] initWithFrame:self.view.bounds];
opacityVw.backgroundColor = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
WPCustomButton *closeBtn = [[WPCustomButton alloc] initWithFrame:CGRectMake(230, 10, 80, 20)];
[closeBtn setTitle:@"Close X" forState:UIControlStateNormal];
[closeBtn setBackgroundColor:[UIColor clearColor]];
[closeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[closeBtn addTarget:self action:@selector(closeView) forControlEvents:UIControlEventTouchUpInside];
[opacityVw addSubview:closeBtn];
}
// ---------------------------------------------------------------------------------------------------------------------
#pragma mark - Button methods
-(void) closeView
{
[opacityVw removeFromSuperview];
}
-(void)setProfileImage
{
[self setOpacityView];
[self.view addSubview:opacityVw];
}
© Stack Overflow or respective owner