iOS:有没有办法通过将所有内容都变灰来使视图控制器看起来不活动? [英] iOS: Is there a way to make a viewcontroller look inactive by having everything grayed out?

查看:25
本文介绍了iOS:有没有办法通过将所有内容都变灰来使视图控制器看起来不活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的 ViewController 和每个对象都显示为非活动状态,让它们全部变灰(有点像 UIAlertView 弹出窗口如何将背景中的所有内容变灰).我不想手动将存在的每个对象都变灰.有没有一种简单的方法可以使这项工作正常进行?

I want my ViewController and every object appear inactive by having it all grayed out (kind of like how the UIAlertView popup grays out everything in the background). I do not want to have to manually gray out every object there is.Is there an easy way to make this work?

推荐答案

UIView *grayView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
grayView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];
[self.view addSubview:grayView];

您可以弄乱白色和 alpha 值以获得您想要的效果,但这应该会在您的视图控制器视图中的所有内容上添加灰色调.

You can mess with the white and alpha values to get exactly what you want, but that should put a gray tint over everything in your view controller's view.

这篇关于iOS:有没有办法通过将所有内容都变灰来使视图控制器看起来不活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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