POP-UP UIView quot;IMDB Appquot; style(POP-UP UIView“IMDB App风格)
问题描述
有没有一种简单的方法来完成这种弹出窗口(就像 UIPopoverController 一样)或者我应该从头开始构建它?
Is there an easy way to accomplish this kind of pop-up window (like there is with UIPopoverController) or should I build it from scratch?
http://dl.dropbox.com/u/1898217/la-照片.jpg
推荐答案
你可以很容易地从头开始制作这样的东西.诀窍是让你的弹出视图控制器有一个全屏透明层
You can make something like this from scratch pretty easily. The trick is to make your popover view controller have a full screen transparent layer
从你的主要观点:
self.popoverController = [[PopoverController alloc]
initWithNibName:@"PopoverViewController" bundle:nil];
self.popoverController.view.frame =
CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:self.popoverController.view]; // view is the transparent background
[self.popoverController viewWillAppear:NO];
如果你想要过渡效果,现在只需实现 viewWillAppear:
Now its just a matter of implementing viewWillAppear if you want transition effects:
- (void) viewWillAppear:(BOOL)animated {
self.fadeView.alpha = 1.0f;
self.view.alpha = 0.0;
[self slideIn];
}
// Slide in with whatever effects you want your popup to use
- (void) slideIn {
//set initial location at bottom of view (my popup slid in from the bottom)
CGRect frame = self.configView.frame;
frame.origin = CGPointMake(0.0, self.view.bounds.size.height);
self.configView.frame = frame;
[self.view addSubview:self.configView];
//animate to new location, determined by height of the view in the NIB
[UIView beginAnimations:@"presentWithSuperview" context:nil];
[UIView setAnimationDuration:0.5];
self.view.alpha = 1.0; // fade in background
frame.origin = CGPointMake(0.0, self.view.bounds.size.height -self.configView.bounds.size.height);
self.configView.frame = frame; // animate in popup
[UIView commitAnimations];
}
- (void) slideOut {
[UIView beginAnimations:@"removeFromSuperviewWithAnimation" context:nil];
[UIView setAnimationDuration:0.5];
self.view.alpha = 0.0;
// Set delegate and selector to remove from superview when animation completes
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
// Move this view to bottom of superview (my popup slides back to the bottom when finished)
CGRect frame = self.configView.frame;
frame.origin = CGPointMake(0.0, self.view.bounds.size.height);
self.configView.frame = frame;
[UIView commitAnimations];
}
// Finally remove the views when you're done animating out.
- (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([animationID isEqualToString:@"removeFromSuperviewWithAnimation"]) {
[self.configView removeFromSuperview];
[self.view removeFromSuperview];
}
}
对于奖励积分,您可以将透明背景设置为控件,并让它检测弹出窗口何时消失的触摸.我使用界面生成器调用了一个调用 slideOut 的操作.
For bonus points you can make the transparent background a control and have it detect touches for when the popup should go away. I used interface builder to call an action which calls slideOut.
这篇关于POP-UP UIView“IMDB App"风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:POP-UP UIView“IMDB App"风格


基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01