简体   繁体   中英

how to set UIView background programmatically

in the interface builder,i can find the background tag,and select the color and the opacity.

if I create the UIView programmatically,if I want to change color,I can set the backgroundColor property

the question is if I want to change the opactiy,What is the property should I change?

Thanks a lot.

使用视图的alpha属性,或者,如果您不希望视图的内容具有相同的不透明度更改,请更改背景颜色的alpha分量(如使用+colorWithRed:green:blue:alpha:+colorWithHue:saturation:brightness:alpha:+colorWithWhite:alpha:以外的其他值。

You can just use

self.alpha = someFloat;

in your view class.

If you want to change it from viewcontroller, use

self.view.alpha = someFloat;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM