如何制作这样的自定义模态 uiview?

发布于 2024-12-11 13:16:20 字数 186 浏览 1 评论 0原文

我需要在 iPhone 应用程序上显示一些模式视图,其中我将显示几个标签、一个 UIImageView 和两个按钮。设计需要完全定制。 这是自定义的 UIAlertView 吗?如何制作类似的东西?

Tweetboot 中的 UIView

I need some modal view on iPhone app where I will display few labels, one UIImageView and two buttons. Design needs to be whole custom.
Is this custom UIAlertView? How to make something similar?

UIView in Tweetboot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夏有森光若流苏 2024-12-18 13:16:20

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

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

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

There is a nice blog post by Jeff LaMarche about how to create a custom Alert View. You can take inspiration from there.

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

** UPDATE on April 24, 2017 **
Unfortunately the blog doesn't exist anymore. However you can retrieve the post from the Web Archive:
https://web.archive.org/web/20160430051146/http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html

胡大本事 2024-12-18 13:16:20

请参阅 Tapku 库的源代码。他们有这个选项 - 你可以随时修改/调整它的源代码。但这并不困难,只是周围有很多层魔法(例如晕影效果)。大多数资产都是图像。你只需要正确地分解它。

See the source for Tapku library. They have this option - you can always hack/tweak source code for it. Its not that difficult though, Just a lot of layer magic going around (e.g. the vignette effect). and most of the assets are images. You just need to break it down properly.

北渚 2024-12-18 13:16:20

您只需按照以下步骤即可获得它:

  1. 创建尺寸为 320*480 的 UIview (ViewA),使其覆盖 iPhone 的整个屏幕,背景设置为clearColor。这将作为我们目的的超级视图;
  2. 创建另一个大小为 320*480 的 UIView (ViewB),背景颜色设置为黑色,不透明度设置为 40%。
    3.现在您可以在ViewB上添加任何视图。
  3. 现在将 ViewB 添加到 ViewA。

最后,您可以在需要时呈现此视图。效果是,ViewA 将覆盖背景视图控制器,ViewB 将作为背景视图控制器的抑制效果,B 上的视图是您将看到的 UIElement。

You can acquire that simply following the following steps

  1. Create UIview (ViewA)of size 320*480 , so that it will cover whole screen of iPhone with background set to clearColor.This will serve as super view for our purpose;
  2. Create another UIView (ViewB) of size 320*480 with background color set to black and opacity to 40%.
    3.Now you can add any view on ViewB.
  3. Now add ViewB to ViewA.

Finally you can Present this view where ever required. The effect will be, ViewA will cover the Background viewController, ViewB will server as suppressing effect for background view controller and views on B are the UIElement you will see.

双手揣兜 2024-12-18 13:16:20

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

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

Making a view like this is simple. You just need to create a custom view with the pieces that you want and just make it hidden or set the alpha to 0.0. Then un-hide it when you want to use it.

To prevent interaction with other items behind the view put a blank semi-transparent view right behind your custom view.

我是男神闪亮亮 2024-12-18 13:16:20
        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];
        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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文