IOS 7 pushing the Limits notes-create a layer like Notification center ' s or control center ' s background

Source: Internet
Author: User
Tags notification center

Problem:

How to create a layer this looks like your Notification center's or control center ' s background

Solution:

Using uiimage+imageeffects to Create a blurred Popup Layer

Code Fragments:

//Create the LayerSelf.layer =[Calayer layer];self.layer.frame= CGRectMake ( the, -, the, the); [Self.view.layer AddSublayer:self.layer];//Take the screenshotfloatScale =[UIScreen Mainscreen].scale; Uigraphicsbeginimagecontextwithoptions (self.view.frame.size, YES, scale); [Self.view drawViewHierarchyInRect:self.view.frame afterscreenupdates:no];__block UIImage*image =Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext ();//Crop the screenshotCgimageref Imageref =Cgimagecreatewithimageinrect (image. Cgimage,cgrectmake (self.layer.frame.origin.x*SCALE,SELF.LAYER.FRAME.ORIGIN.Y*Scale,self.layer.frame.size.width*Scale,self.layer.frame.size.height*scale )); Image=[UIImage imagewithcgimage:imageref];//Apply The effectimage = [Image applyblurwithradius:50.0ftintcolor:[uicolor colorwithred:0Green1Blue0Alpha0.1]saturationdeltafactor:2Maskimage:nil];//assign it to the new layer ' s contentsSelf.layer.contents = (__bridgeID) (image. Cgimage);

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.