Romowski
Romowski

Reputation: 1548

How to correctly set alpha of UIView? [iOS]

I have UIView with lots of subviews (UILabel, UITextView, etc.).

If a set alpha 0.6 to main view all the subviews takes this alpha.

How to set alpha separately of main view?

Upvotes: 7

Views: 9123

Answers (2)

the1pawan
the1pawan

Reputation: 1204

 [view setBackgroundColor:[[UIColor clearColor] colorWithAlphaComponent:0.5]];

 //try this.. dont try to set alpha of UIView and also your subviews will not affect

Upvotes: 15

Lithu T.V
Lithu T.V

Reputation: 20021

myView.layer.shouldRasterize = YES

This will make it use group opacity and everything should composite as you'd expect.

Upvotes: 0

Related Questions