IOS 8.0 frosted Glass effect Uivisualeffect

Source: Internet
Author: User

With the release of iOS8.0 and OS X 10.0, a large number of frosted glass effects are everywhere.

We used to achieve the effect of frosted glass, more through the cgimage to achieve. Now, the XCode6 comes with the API.API to achieve this effect, as follows:

typedef ns_enum (Nsinteger, Uiblureffectstyle) {uiblureffectstyleextralight, uiblureffectstylelight, UIBlurEffect Styledark} ns_enum_available_ios (8_0); Ns_class_available_ios (8_0) @interface uivisualeffect:nsobject <nscopying, nssecurecoding> @end/* UIBlurEffect Would provide a blur that appears to having been applied to the content layered behind the uivisualeffectview. Views added to the Contentview of a blur visual effect is not blurred themselves. */ns_class_available_ios (8_0) @interface uiblureffect:uivisualeffect+ (Uiblureffect *) Effectwithstyle: ( Uiblureffectstyle) style; @end/* Uivibrancyeffect amplifies and adjusts the color of content layered behind the view, Allowi Ng content placed inside the Contentview to become more vivid. It is intended to being placed over, or as a subview of, a uivisualeffectview that have been configured with a uiblureffect. This effect is affects content added to the Contentview. Because the vibrancy effect is color dependent, subviews addEd to the Contentview need to being tintcolordidchange aware and must be prepared to update themselves accordingly. Uiimageview would need its image to has a rendering mode of uiimagerenderingmodealwaystemplate to receive the proper EFFEC T. */ns_class_available_ios (8_0) @interface uivibrancyeffect:uivisualeffect+ (Uivibrancyeffect *) Effectforblureffect: (Uiblureffect *) blureffect; @endNS_CLASS_AVAILABLE_IOS (8_0) @interface Uivisualeffectview: UIView <NSSecureCoding> @property (nonatomic, retain, ReadOnly) UIView *contentview; Do not add subviews directly to Uivisualeffectview with this view instead. @property (nonatomic, copy, ReadOnly) Uivisua Leffect *effect;-(Instancetype) Initwitheffect: (Uivisualeffect *) effect Ns_designated_initializer; @end

@ Test Code:

    Picture    Uiimageview *imageview = [[Uiimageview alloc] Initwithframe:cgrectmake (ten, +, +)];    [ImageView setimage:[uiimage imagenamed:@ "img_0015.jpg"];    [Self.view Addsubview:imageview];        Blur effect    Self.visualefview = [[Uivisualeffectview alloc] Initwitheffect:[uiblureffect effectwithstyle: Uiblureffectstylelight]];    _visualefview.frame = CGRectMake (0, 0, +);    _visualefview.alpha = 1.0;    [ImageView Addsubview:_visualefview];
@Demo Running Effect:


IOS 8.0 frosted Glass effect Uivisualeffect

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.