iOS Development View properties hidden, opaque, alpha, opacity differences

Source: Internet
Author: User

First, AlphaThe liquid crystal display is composed of pixel dots, each pixel can display a color value composed of the Rgba color space. A is a representation of the transparency Alpha,uiview Alpha is a floating-point value, and the range of values is 0~1.0, from full transparency to completely opaque. 1, Alpha will affect their transparency, but also affect the transparency of subview. 2. After the alpha is set to NULL, the UIView is not removed from the responder chain and can still receive the event. 3, change the alpha, the default is animation effect,This is because the layer is represented in cocoa by the Calayer in core animation, which is an implicit animation of Calayer. Of course there are ways to disable this animation effect.

Hidden this property is a bool value, which is used to indicate whether the UIView is hidden and the default value is No. When the value is set to Yes: 1, the current UIView and Subview will be hidden, regardless of the subview hidden. 2. The current uiview is removed from the responder chain, and the next in the responder chain becomes the first responder
Third, Alpha-hidden comparison 1, the impact on Subview: Alpha will affect subview transparency, hidden also affect subView2, hide Uiview:alpha set to 0 can hide UIView, Hidden set to Yes can also hide uiview, the effect is the same, the use of hidden performance is high.
Opaque The property is a bool value, the default value for UIView is yes, but the default value for subclasses such as UIButton is No. Opaque indicates whether the current UIView is opaque, but the funny thing is the factIt doesn't make a decision about whether the current UIView is opaque ., for example, if you set opaque to No, the UIView will still be visible. The function is: to provide a performance optimization switch for the drawing system. If the value is yes, the drawing will treat the entire view as opaque when drawing the view. In this way, the drawing system optimizes some operations and provides system performance during the drawing process, and if set to No, the drawing system treats it and other content equally and does not perform optimization operations. For performance reasons, the default is set to Yes (meaning optimization). 1, UIView when there is a background color: and the background color is transparent (opacity is not 1 o'clock), set opaque to Yes high performance. 2. When the UIView has a background color: and the transparency of the background color is 1,opaque the value does not affect performance. 3, UIView no background color: The value of opaque does not affect performance.
The Opacity-calayer attribute Calayer in opacity is a floating-point value, with a range of 0~1.0, from completely transparent to completely opaque. 1, opacity will affect their own transparency, but also affect the transparency of sublayer. 2. After opacity is set to NULL, Calayer will not be removed from the responder chain and will still receive the event.
Vi. how to set UIView transparent, subview opaque 1, use a translucent picture to do the background. This method can achieve the requirements, but the project should be as few as possible to add resources, can not use pictures as far as possible without pictures. 2, use Colorwithwhite:alpha: Method view.backgroundcolor = [Uicolor colorwithwhite:0.f alpha:0.5]; This is also used more methods, The parameters behind white represent grayscale, from 0-1 to black, and alpha is the transparency you want to adjust. 3. Use ColorWithRed:green:blue:alpha: Method setting Alpha is the transparency you want to adjust. 4. Set the background in Xib or storyboard
Adjust the transparency by opacity the slider in the background color settings graph. 5. Using Colorwithalphacomponent: MethodThis is an instance method, and a Uicolor instance calls this method and returns a uicolor with transparency. Use the following method:
UIColor *color = [UIColor blackColor];bgView.backgroundColor = [color colorWithAlphaComponent:0.5];



View properties for iOS development hidden, opaque, alpha, opacity differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.