如何从屏幕底部呈现UIView像UIActionSheet? [英] How can I present a UIView from the bottom of the screen like a UIActionSheet?
问题描述
我想要一个UIView从屏幕底部向上滑动(并保持中间屏幕)像UIActionSheet。
I'd like a UIView to slide up from the bottom of the screen (and stay mid-screen) like a UIActionSheet. How can I accomplish this?
UPDATE:
我使用以下代码:
UPDATE: I am using the following code:
TestView* test = [[TestView alloc] initWithNibName:@"TestView" bundle:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.4];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
test.view.center = CGPointMake(160,100);
//test.view.frame = CGRectMake(0, 0, 160, 210);
[[[UIApplication sharedApplication] keyWindow] addSubview:test.view];
[UIView commitAnimations];
视图似乎是从角落开始动画并出现在角落。如何让它从底部滑动?接近!
The view seems to be animating from the corner and appearing in the corner. How can I make it slide up from the bottom? Getting close!
推荐答案
Matt做了这里,但只是改变了值和方向。
Do what Matt did here, but just change the values and direction. I have code at home to do this from the bottom if you need it later (I'll update this post).
链接: http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on。 html
此外,不要忘记取出一些代码,将主视图向下移动(因此,UIView只是像上面一样弹出ActionSheet)
Also, don't forget to take out the bit of code that shifts the main view downward (so instead the UIView just pops over top like an ActionSheet)
已更新为代码:
显示/隐藏一些选项视图:
This is what I use in one of my apps to show/hide a little "options" view:
- (void)toggleOptions:(BOOL)ViewHidden
{
// this method opens/closes the player options view (which sets repeat interval, repeat & delay on/off)
if (ViewHidden == NO)
{
// delay and move view out of superview
CGRect optionsFrame = optionsController.view.frame;
[UIView beginAnimations:nil context:nil];
optionsFrame.origin.y += optionsFrame.size.height;
optionsController.view.frame = optionsFrame;
[UIView commitAnimations];
[optionsController.view
performSelector:@selector(removeFromSuperview)
withObject:nil
afterDelay:0.5];
[optionsController
performSelector:@selector(release)
withObject:nil
afterDelay:0.5];
optionsController = nil;
}
else
{
optionsController = [[PlayOptionsViewController alloc] init];
//
// Position the options at bottom of screen
//
CGRect optionsFrame = optionsController.view.frame;
optionsFrame.origin.x = 0;
optionsFrame.size.width = 320;
optionsFrame.origin.y = 423;
//
// For the animation, move the view up by its own height.
//
optionsFrame.origin.y += optionsFrame.size.height;
optionsController.view.frame = optionsFrame;
[window addSubview:optionsController.view];
[UIView beginAnimations:nil context:nil];
optionsFrame.origin.y -= optionsFrame.size.height;
optionsController.view.frame = optionsFrame;
[UIView commitAnimations];
}
}
这篇关于如何从屏幕底部呈现UIView像UIActionSheet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!