显示半个模态视图的方法

来源:互联网 发布:网络暴力调查问卷 编辑:程序博客网 时间:2024/06/05 19:44

Present a view Controller that is half the size of the screen

up vote4down votefavorite
1

I'm trying to present a view controller thats only half the height using

[self presentModalViewController:menu animated:YES];

The problem is when it's presented, the view controller ends the same size as the screen. I've also tried making the 'menu' the full size of the screen and changing the view's transparency to white but that doesn't work either.

share|improve this question
 

3 Answers

activeoldestvotes
up vote7down voteaccepted

Just use core animation or animation transitions with a UIView that is half the size of the screen. You'll need a holder view that you add to the main view.

Place the half sized view below the screen (halfView.y = 480 or 320 depending on orientation).

Animate it upwards.

Something like this maybe:

// set up an animation for the transition between the views    CATransition *animation = [CATransition animation];    [animation setDuration:0.5];    [animation setType:kCATransitionPush];    [animation setSubtype:kCATransitionFromBottom];    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];    [holderView addAnimation:animation forKey:@"SwitchToView1"];
share|improve this answer
0 0