First there are 4 of these classes
Uivisualeffect
Uiblureffect
Uivibrancyeffect
Uivisualeffectview
Inheritance relationship
Uivisualeffect: nsobject
|-> Uiblureffect
|-> Uivibrancyeffect
Uivisualeffectview: UIView
From Baidu translation (this is not easy to learn programming)
Visual
(of visual acuity);
Blur
N. stain, stain, stains; a vague thing; Ambiguous
vt.& VI. to smear or stain; (to) become blurred (make) difficult to distinguish;
Effec
N. Impact; Effect Impression All things;
Vt. to make happen; Cause produce (effect);
Vibrancy
N. vibration; The sound of vibration; Active Dynamic
Initialization
typedef ns_enum (Nsinteger, Uiblureffectstyle) {
uiblureffectstyleextralight,//-Highlighted style
The style of uiblureffectstylelight,//lighting
uiblureffectstyledark//of the Dark style
} ;
Uiblureffect *blur = [uiblureffect effectwithstyle:uiblureffectstyledark];
Uivisualeffectview *vise = [[uivisualeffectview alloc] initwitheffect: Blur];
然后这样
Uiimageview * view = [[Uiimageview alloc]initwithframe:cgrectmake (0,0, Self.view.frame.size.width, Self.view.frame.size.height)]; UIImage* img = [UIImage imagenamed:@"1.jpg"]; Uivisualeffectview* Effectview =[[Uivisualeffectview Alloc]initwitheffect:[uiblureffect Effectwithstyle:uiblureffectstyleextralight]]; //set the degree of the BlurEffectview.alpha=1.0; Effectview.frame=cgrectmake (0,0, Self.view.frame.size.width, $); View.image=img; [View Addsubview:effectview]; [Self.view Addsubview:view];
The result is this (there is no text at this time, it will be in the code later)
There is also a style
Note the text, here's how it's initialized
1.
Uiblureffect *blur = [Uiblureffect Effectwithstyle:uiblureffectstyledark]; *vibrancy = [Uivibrancyeffect Effectforblureffect:blur]; *vise = [[Uivisualeffectview alloc] initwitheffect:vibrancy];
2. You need to add the label to the Contentview
[Vise.contentview Addsubview:lab];
Uiblureffect is the entire background of the virtual, Uivibrancyeffect is added to the label and other attachments to the background of the blur. Note that these attachments must be added to the Uivisualeffectview Contentview, otherwise it will not have any effect.
iOS8 Wool Glass effect (Uivisualeffectview)