在iPhone的灰色视图,怎么样? [英] Gray out view in iphone, how?

查看:145
本文介绍了在iPhone的灰色视图,怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是灰色显示视图部分的方式,类似于UIAlertView除了消息框之外的所有内容?现在我在目标区域的顶部使用另一个自定义视图,但它看起来不太好。

I wonder what is the way to gray out portion of a view similar to the way UIAlertView grays out everything except the message box? Right now i use another custom view on top of the target area, but it doesnt look as nice.

任何想法?

推荐答案

使用您已经尝试过的方法我得到了很好的结果。或许摆弄阿尔法是一个好主意?

I get good results using the method you have already tried. perhaps fiddling around with the alpha is a good idea?

mask = [[UIView alloc] initWithFrame:window.frame];
[mask setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.78]];
[self.view addSubview:mask];

然后在你的代码中你可以删除它:

Then later in your code you can remove it:

[mask removeFromSuperview];
or
[mask setHidden:YES];

如果你想让它变得更好,我想你可以尝试使用渐变,无论是以编程方式,或者作为图像,并使用它来使屏幕边缘变暗,使得显示在最前面的内容看起来像是光源。

If you want to make it even better, I suppose you could try using a gradient, either programmatically, or as an image, and using this to darken the edges of the screen such that the content you are displaying forefront appears to be the light source.

这篇关于在iPhone的灰色视图,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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