2011-10-24 29 views

回答

6

Jeff LaMarche有一篇很好的博客文章,介绍如何创建自定义警报视图。你可以从那里获得灵感。

http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html

** 2017年** 4月24日,UPDATE不幸的是,博客已经不存在了。但是,您可以从Web存档中检索该帖子: https://web.archive.org/web/20160430051146/http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html

+0

真的很不错,谢谢。我必须阅读它来找出什么是我的情况最好的解决方案 – dormitkon

+0

可悲的是,这篇博文已不再可用 – dacoinminster

+0

添加到网络存档的链接。 – viggio24

1

制作这样的图是简单的。您只需要创建一个自定义视图,并将其隐藏起来,或者将alpha设置为0.0。然后当你想使用它时取消隐藏它。

为了防止与视图后面的其他项目进行交互,请在您的自定义视图后面放置一个空白的半透明视图。

2

请参阅Tapku库的来源。他们有这个选项 - 你可以随时对它的源代码进行破解/调整。尽管如此,它并不那么困难,只是很多层层魔法(例如小插曲效果)。并且大部分资产都是图片。你只需要正确地分解它。

+0

我会给他们一个尝试,thks :) – dormitkon

0
 UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"\n\Please wait. \n Authorising Credentials..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease]; 
     UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(220, 10, 40, 40)]; 
     NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"smile.png"]]; 
     UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path]; 
     [imageView setImage:bkgImg]; 
     [bkgImg release]; 
     [path release]; 
     [alert addSubview:imageView]; 
     [imageView release]; 
     [alert addButtonWithTitle:@"Cancel"]; 
     [alert show]; 
+0

我需要更多的自定义视图。谢谢 – dormitkon

2

您可以获取,简单地按照以下步骤

  1. 创建的UIView(ViewA)的尺寸为320 * 480的,所以它的内容将涵盖背景iPhone的整个屏幕设置为clearColor.This会作为我们目的的超级观点;
  2. 创建另一个尺寸为320 * 480的UIView(ViewB),背景颜色设置为黑色,不透明度设置为40%。 3.现在您可以在ViewB上添加任何视图。
  3. 现在将ViewB添加到ViewA。

最后,您可以在任何需要的地方展示此视图。效果将是,ViewA将覆盖Background viewController,ViewB将服务器作为背景视图控制器的抑制效果,而B上的视图是您将看到的UIElement。