gpt4 book ai didi

iphone - 我怎样才能像 UIActionSheet 一样从屏幕底部呈现一个 UIView?

转载 作者:太空狗 更新时间:2023-10-30 03:29:07 24 4
gpt4 key购买 nike

我希望 UIView 像 UIActionSheet 一样从屏幕底部向上滑动(并保持在屏幕中间)。我怎样才能做到这一点?

更新:我正在使用以下代码:

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];

View 似乎从角落开始动画并出现在角落里。我怎样才能让它从底部向上滑动?越来越近了!

最佳答案

做 Matt 在这里所做的,但只是改变值(value)观和方向。如果您以后需要,我家里有代码可以从底部开始执行此操作(我会更新这篇文章)。

链接:http://cocoawithlove.com/2009/05/intercepting-status-bar-touches-on.html

此外,不要忘记删除将主视图向下移动的代码(这样 UIView 就像 ActionSheet 一样从顶部弹出)

更新代码:

这是我在我的一个应用程序中用来显示/隐藏一个小“选项” 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];
}
}

关于iphone - 我怎样才能像 UIActionSheet 一样从屏幕底部呈现一个 UIView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3357034/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com