Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly set alpha of UIView? [iOS]

Tags:

ios

uiview

alpha

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?

like image 376
Romowski Avatar asked Jun 13 '13 04:06

Romowski


People also ask

What is UIView in Android?

An object that manages the content for a rectangular area on the screen. Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. A view object renders content within its bounds rectangle, and handles any interactions with that content.

Does changing the alpha value of a subview change its contents?

Changing the value of this property updates the alpha value of the current view only. However, the transparency imparted by that alpha value affects all of the view's contents, including its subviews.

How do I animate a UIView property change?

To animate your changes, create a UIViewPropertyAnimator object and use its handler block to change the values of your view's properties. The UIViewPropertyAnimator class lets you specify the duration and timing of your animations, but it performs the actual animations.

Why do I need glkview instead of UIView?

Because it waits until the next drawing cycle to update the view, you can call these methods on multiple views to update them at the same time. If you are using OpenGL ES to do your drawing, you should use the GLKView class instead of subclassing UIView.


1 Answers

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

 //try this.. dont try to set alpha of UIView and also your subviews will not affect
like image 108
the1pawan Avatar answered Oct 12 '22 19:10

the1pawan