Uivisualeffectview achieves two kinds of blur effects:Uiblureffect and Uivibrancyeffect
Both are inherited from the UIView, the former placed in any view inside can be rendered to the next volume of the views of the blur effect, the latter is on the basis of the former glass effect on the upper layer of the view to highlight the processing
The code is as follows:
@IBOutlet weak var imageview:uiimageview!
Override Func Viewdidload () {super.viewdidload () var blureffect = Uiblureffect (style:UIBlurEffectStyle.Lig HT) var Blureffectview = Uivisualeffectview (effect:blureffect) blureffectview.frame = View.frame vie W.addsubview (Blureffectview) var vibrancyeffect = Uivibrancyeffect (forblureffect:blureffect) Var VI Brancyeffectview = Uivisualeffectview (effect:vibrancyeffect) vibrancyeffectview.frame = View.frame var label = UILabel () Label.text = "Vibrant label!!!" Label.font = Uifont.systemfontofsize (72.0) label.sizetofit () Label.center = View.center VIBRANCYEFFEC TView.contentView.addSubview (label) BlurEffectView.contentView.addSubview (Vibrancyeffectview) var b TN = UIButton (Frame:cgrect (x:300, y:450, width:300, height:100)) btn.settitle ("Change Basemap", forstate:uicontrolstate . Normal) Btn.addtarget (Self, Action: "Updatebackimage:", ForcontrolevenTs:UIControlEvents.TouchUpInside) VibrancyEffectView.contentView.addSubview (BTN)}
Func Updatebackimage (sender:anyobject) { imageview.image = UIImage (named: "Z") }
The effect after running:
Click on the "Change Basemap button" background to switch to another graph, the blur effect is updated in time:
The effect is quite cool??
The effect Uivisualeffectview of IOS8 fuzzy frosted glass