如何创建自定义UIAlertView [英] How to create custom UIAlertView

查看:95
本文介绍了如何创建自定义UIAlertView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在创建一个身临其境的应用程序,需要具有与 UIAlertView 类似的东西,但我们不希望它看起来像一个系统对话框,我们想使用我们自己的图形。我有一大块的工作,但有一些阻碍我击中:

We're creating an immersive app that needs to have something that acts rather similar to a UIAlertView, but we don't want it to look like a system dialog, we want to use our own graphics. I've got a big chunk of the work done, but there are a few snags I've hit:


  1. 如何做我使UIView显示在状态栏上方(这样我可以变暗,像 UIAlertView )?这可能吗?

如何显示它部分透明,但文字仍然完全显示在窗口中,但它仍然显示在状态栏下面。不透明?我想让它显示类似于 UIAlertView ,它应该是半透明的,但如果我设置alpha为.8,这也减少了子视图的alpha。如果我只减少背景图像的alpha,那么按钮看起来不透明。如果我减少背景图像和按钮的alpha,那么按钮看起来不像它们嵌入在背景图像中。我非常希望不必为每个嵌入按钮的排列创建不同的图片

How do I show it partially transparent but have the text still fully opaque? I want it to be shown similar to a UIAlertView in that it should be translucent, but if I set alpha to .8, that also decreases the alpha of subviews. If I only decrease the alpha of the background image, then the buttons appear opaque. If I decrease the alpha of the background image and the buttons, then the buttons don't look like they are embedded in the background image. I would very much like to not have to create a different image for each arrangement of embedded buttons

我还没有找到解决状态栏问题,但我注意到,一个标准的UIAlertView显示在自己的UIWindow,当我调查,我发现了windowLevel属性:

I haven't yet found a solution to the status bar issue, but I've noticed that a standard UIAlertView shows up in its own UIWindow, and when I investigated that, I found the windowLevel property:

const UIWindowLevel UIWindowLevelNormal;
const UIWindowLevel UIWindowLevelAlert;
const UIWindowLevel UIWindowLevelStatusBar;

使用自己的UIWindow与 UIWindowLevelAlert 不要使其显示在状态栏上方。我没有尝试 UIWindowLevelStatusBar

Using my own UIWindow with UIWindowLevelAlert still didn't make it show up above the status bar. I didn't try UIWindowLevelStatusBar.

推荐答案

我使UIView显示在状态栏上方(这样我可以变暗,像UIAlertView)?这是可能的吗?

我不认为苹果使用这个非 - UIAlertView UIView 的子类。

I don't think Apple makes this available to a non-UIAlertView subclass of UIView.

UIAlertView UIView 。您是否尝试用自己的绘图代码子类化 UIAlertView 并覆盖 -drawRect:

UIAlertView is a subclass of UIView. Have you tried subclassing UIAlertView and overriding -drawRect: with your own drawing code?

这篇关于如何创建自定义UIAlertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆