How can I have an opaque UIView as a subview of a semi-transparent UIView?

Set the UIView background color alpha not it’s alpha directly.

Objective-C

UIView *view;
...
view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.6];

It’s not the same as:

view.backgroundColor = [UIColor blackColor];    
view.alpha = .6;

Swift

view.backgroundColor = UIColor.black.withAlphaComponent(0.6)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)