Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overlaying UIViews

what is the appropriate way to overlay two layers of an UIView for the iPhone? The underlaying view should be active until a button is pressed, then another UIView should cover everything in a transparent way. I found the Modal View Controllers, but they simply exchange UI-Views but don't overlay.

Thanks in advance.

Chris

like image 855
Chris Avatar asked Mar 01 '26 03:03

Chris


1 Answers

You should use [existingView addSubview:newView]; to add a view to an existing view. the newView will appear on top of the existingView. So conceptually, you would create a button on existingView, connect it to an IBAction that calls a method like this:

CGRect newSize = CGRectMake(0.0f ,0.0f, 320.f, 400.0f);
UIView *newView = [[UIView alloc] initWithFrame:newSize];
[existingView addSubview:newView];
[newView release];

This will place a newView on top of the existingView.

like image 68
Jordan Avatar answered Mar 05 '26 05:03

Jordan