bin
bin

Reputation: 11

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.

Upvotes: 1

Views: 2364

Answers (2)

EEE
EEE

Reputation: 4536

You can just use

self.alpha = someFloat;

in your view class.

If you want to change it from viewcontroller, use

self.view.alpha = someFloat;

Upvotes: 1

Noah Witherspoon
Noah Witherspoon

Reputation: 57139

Use the view's alpha property, or, if you don't want the view's content to have the same opacity change applied to it, change the alpha component of the background color (as created with +colorWithRed:green:blue:alpha:, +colorWithHue:saturation:brightness:alpha:, or +colorWithWhite:alpha:) to something other than 1.

Upvotes: 4

Related Questions