The use of iOS8 blur effect Uivisualeffectview
Effect:
Source:
////VIEWCONTROLLER.M//Effectview////Created by Xianmingyou on 15/3/14.//Copyright (c) 2015 xianmingyou. All rights reserved.//#import "ViewController.h"@interfaceViewcontroller () @property (nonatomic, strong) Uivisualeffectview*Effectview, @property (nonatomic, strong) Uivisualeffectview*Vibrancyeffectview, @property (nonatomic, strong) Uiscrollview*ScrollView;@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //Add a Test View[Self.view AddSubview:self.scrollView]; //add blur with View[Self.view AddSubview:self.effectView]; //add additional view (with Contentview)[Self.effectView.contentView AddSubview:self.vibrancyEffectView];}@synthesizeScrollView =_scrollview;-(Uiscrollview *) ScrollView {if(_scrollview = =Nil) {_scrollview=[[Uiscrollview alloc] initWithFrame:self.view.bounds]; _scrollview.showshorizontalscrollindicator=NO; _scrollview.showsverticalscrollindicator=NO; _scrollview.bounces=NO; Uiimageview*imageview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"color.jpg"]]; _scrollview.contentsize=imageView.image.size; [_scrollview Addsubview:imageview]; } return_scrollview;}@synthesizeEffectview =_effectview;-(Uivisualeffectview *) Effectview {if(_effectview = =Nil) { //add Blur effect_effectview =[[Uivisualeffectview alloc] Initwitheffect:[uiblureffect Effectwithstyle:uiblureffectstylelight]]; _effectview.userinteractionenabled=NO; _effectview.frame= CGRectMake (0,0, the, $); _effectview.center=Self.view.center; } return_effectview;}@synthesizeVibrancyeffectview =_vibrancyeffectview;-(Uivisualeffectview *) Vibrancyeffectview {if(_vibrancyeffectview = =Nil) { //Initializing textUILabel *label =[[UILabel alloc] initWithFrame:self.effectView.bounds]; Label.text=@"youxianming"; Label.font= [Uifont systemfontofsize: +. f]; Label.textalignment=Nstextalignmentcenter; //need to be consistent with the effect of Effectview_vibrancyeffectview = [[Uivisualeffectview alloc] initwitheffect:[uivibrancyeffect effectforblureffect: ( Uiblureffect *) [Self.effectView.effect]]; _vibrancyeffectview.frame=Self.effectView.bounds; //Note that the Contentview is used to add a label[Self.vibrancyEffectView.contentView Addsubview:label]; } return_vibrancyeffectview;}@end
Picture for testing:
IOS8 use of blur effects Uivisualeffectview