Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView and subviews - opacity

Tags:

Is it possible to make a UIView (and any other subviews within it) set to an opacity of say 0.5 or whatever? Not sure if this is even possible, but want to ask.

like image 218
mootymoots Avatar asked Feb 25 '10 14:02

mootymoots


People also ask

What is a UIView?

UIView can be defined as an object by using which we can create and manage the rectangular area on the screen. We can have any number of views inside a view to create a hierarchical structure of the UIViews. The UIView is managed by using the methods and properties defined in the UIView class that inherits UIKit.

What is opaque ios?

An opaque view is expected to fill its bounds with entirely opaque content—that is, the content should have an alpha value of 1. 0 . If the view is opaque and either does not fill its bounds or contains wholly or partially transparent content, the results are unpredictable.

What is opaque property?

Definition and Usage The opacity property sets the opacity level for an element. The opacity-level describes the transparency-level, where 1 is not transparent at all, 0.5 is 50% see-through, and 0 is completely transparent.

How do I change opacity in Swift?

Any SwiftUI view can be partially or wholly transparent using the opacity() modifier. This accepts a value between 0 (completely invisible) and 1 (fully opaque), just like the alpha property of UIView in UIKit.


1 Answers

view.alpha = 0.5; // Doesn't it work? 
like image 73
Vladimir Avatar answered Oct 27 '22 10:10

Vladimir