Gray out view in iphone, how?

房东的猫 提交于 2019-12-09 04:24:26

问题


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.

Any ideas?


回答1:


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.



来源:https://stackoverflow.com/questions/1431021/gray-out-view-in-iphone-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!