The effect Uivisualeffectview of IOS8 fuzzy frosted glass

Source: Internet
Author: User

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

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.