I am adding a modal view using the following code:
[self presentModalViewController:phrasesEditor animated:YES];
How can I make the modal view semi-transparent so that the superview “shines” through?
My complete method/function looks like this:
-(IBAction)showEditPhrases:(id)sender{
PhrasesViewController *phrasesEditor = [[PhrasesViewController alloc] initWithNibName:@"PhrasesViewController" bundle:nil];
phrasesEditor.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[phrasesEditor.view setAlpha: 0.5];
[phrasesEditor.view setBackgroundColor: [UIColor clearColor]];
[self presentModalViewController:phrasesEditor animated:YES];
[phrasesEditor release];
}
EDIT:
The pragmatic approach of changing the alpha will not work, apparently. How can I load a NIB into a UIView and interact with it?
I have a UIViewController now. Do I convert/modify/change it into a UIVIew and then load it, or am I supposed to do something else?
EDIT 2:
I tried [self.view addSubview:phrasesEditor.view];, but that leaves me with no way to remove the subview. Each view seems to have its own View Controller.
EDIT 3:
I thought that I should mention that the superview is inside of a view controller called iDecideViewController and the phrasesEditor has a separate View Controller.
When you present a modal view it will actually unload the previous view so that is not what you want at all. UIView has a method called addSubview which will put the new view on top of its siblings.
Instead of:
do:
This is assuming you are already in a ViewController subclass.