Simple use of the iOS mask layer

Source: Internet
Author: User

/** Big Picture*/-(ibaction) bigimg {//1. Add a button matte layerUIButton *cover=[[UIButton alloc] init]; Cover.frame=Self.view.bounds; Cover.backgroundcolor=[Uicolor Blackcolor]; Cover.alpha=0.0;    [Cover addtarget:self action: @selector (SMALLIMG) forcontrolevents:uicontroleventtouchupinside];    [Self.view Addsubview:cover]; Self.cover=cover; //2. Update the location of the shadow and Avatar[Self.view BringSubviewToFront:self.iconImage]; //[UIView Beginanimations:nil Context:nil]; //Perform an animated mask layer to display slowly[UIView animatewithduration:1.0animations:^{Cover.alpha=0.7;//Set TransparencyCGFloat iconw=Self.view.frame.size.width; CGFloat Iconh=iconw; CGFloat IconX=0; CGFloat Icony= (SELF.VIEW.FRAME.SIZE.HEIGHT-ICONH) *0.5; //CGRect myframe=self.iconimage.frame;self.oldrect=Self.iconImage.frame; Self.iconImage.frame=CGRectMake (IconX, Icony, Iconw, Iconh);        }]; //[UIView commitanimations];}/** Small Map*/-(ibaction) smallimg{[UIView animatewithduration:1.0animations:^{        //1. Code that needs to execute the animation//1.1 Retract iconSelf.iconimage.frame=Self.oldrect; Self.cover.alpha=0.0; } Completion:^(BOOL finished) {//2 code executed after the animation is complete//2.1 Clear Shadows[Self.cover Removefromsuperview]; Self.cover=Nil; }];}

Simple use of the iOS mask layer

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.