/** 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