joec
joec

Reputation: 3543

Present UIView modally that nots full screen

I have a view 200 x 150 px which i would like to present on the tap of a button. If i use addSubview: then the view shows up in the correct position, but i can still tap other buttons on the superview, which is behaviour i don't want.

If i use presentModalViewController then the view takes up the whole screen, which is what i don't want either... this happens even if i set wantsFullScreenLayout to NO.

How can i present the view so that the user can only interact with controls on the presented view?

Thanks

Upvotes: 2

Views: 1884

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55334

Make the view the size of the screen (taking the status bar into account). That view should have a translucent background color (or clear). Have the 200x150 view be on the bottom of that view to have the appearance of a UIActionSheet, where the background dims and the user cannot interact with other elements on the screen.

Then, you can use presentModalViewController to present the view.

Addition

In the view controller's .m file, define awakeFromNib:

-(void)awakeFromNib
{
    self.view.backgroundColor = [UIColor clearColor];
}

Upvotes: 3

Related Questions