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