Detailed Tintcolor Properties

Source: Internet
Author: User

The Tintcolor property is a newly added property after IOS7, which defines a non-default shading color value whose setting affects the entire view hierarchy in view as the root view. It mainly changes the color of the control to get some interesting visual effects.
    • Tintcolor Property-By default, the Tintcolor property is nil by default, and when we set the Tintcolor property of a view, he automatically propagates to his child view, so to set the color of a control, it is necessary to set the Tintcolor of his parent view, When you do not set Tintcolor, the system defaults to blue.
    • There is also a Tintadjustmentmode property associated with the Tintcolor property, which is an enumeration value that defines the adjustment mode for tint color.
typedef ns_enum (Nsinteger, Uiviewtintadjustmentmode) {        uiviewtintadjustmentmodeautomatic,// The shaded adjustment mode of the view is consistent with the parent view The Tintcolor property of the //  View returns the completely unmodified view shading color         uiviewtintadjustmentmodedimmed,                  // the Tintcolor property of the view returns a de-saturation, dimmed view coloring color     } ns_enum_available_ios (7_0);
    • Tintcolordidchange Method-This method is called automatically when the Tintcolor or Tintadjustmentmode property of the view changes. Also, this method is called if the Tintcolor or Tintadjustmentmode property of the parent view of the current view changes. We can refresh our view as needed in this method.

Example:

In the picture below I dragged a few controls in the storyboard, with buttons, labels, sliders, ImageView, and of course not set Tintcolor

When I change Self.view's tintcolor to red, the following

As above, you can see that you can change the color of a lot of controls by changing a Tintcolor property, and when you want to modify all of his control colors in an app, you can alter the window's Tintcolor in the appdelegate. I tried to print the default Tintcolor and Tintadjustmentmode, respectively outputting [uidevicergbcolorspace 0 0.478431 1 1] and 1, which was not set any tint for the entire view hierarchy. The output of a color-related value. As you can see, although we have not set Tintcolor, it still returns the default value of the system, while Tintadjustmentmode returns the original value of normal as default.

    NSLog (@ "%@", Self.view.tintColor);        NSLog (@ "%ld", Self.view.tintAdjustmentMode);         = [Uicolor Redcolor];

Perhaps some classmates see here to wonder, not to say tintcolor can change the color of the child view? How does the color of the above label and ImageView not change, this question, actually very simple, we can by rewriting tintcolordidchange this method to monitor tintcolor change, when self. When the tintcolor color of the view changes, you can set the color of the label font. ImageView's color didn't change because we didn't set the Imagewithrenderingmode property of the picture to Alwaystemplate

Detailed Tintcolor Properties

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.