IOS Animation Preliminary
1. The use of Calayer (layer) belongs to the quartzcore.framework Framework cross-platform
The controls inside the uikit.framework we used in development were visible, mainly because he had calayer.
1 //-------------------------------------------------------------------------2 //Layer Section Properties3 4 //Shadow is transparent5Self.myView.layer.shadowOpacity =1.0f;6 7 //Shadow color8Self.myView.layer.shadowColor =[Uicolor Redcolor]. Cgcolor;9 Ten //Shadow Radius OneSelf.myView.layer.shadowRadius =10.0f; A - //fillet radius of layer -Self.myView.layer.cornerRadius =5; the - //Layer Border Color -_myview.layer.bordercolor =[Uicolor Whitecolor]. Cgcolor; - + //Layer Border Radius -_myview.layer.borderwidth =Ten; + //-------------------------------------------------------------------------
Calayer animated when setting part of a property, (hidden test animation) has a animatable related comment and comes with a hidden test animation
Such as:
1 /* */23@property cgsize shadowoffset; 4 5 /* animatable */ 6 7 @property cgfloat Shadowradius;
Use of Calayer
1Calayer *lay =[Calayer layer];2Lay.backgroundcolor =[Uicolor Redcolor]. Cgcolor;3Lay.shadowopacity =1.0;4Lay.shadowcolor =[Uicolor Whitecolor]. Cgcolor;5Lay.shadowradius =Ten;6Lay.cornerradius =5;7Lay.maskstobounds =YES;8 [Self.view.layer Addsublayer:lay];9 Ten //Set Image OneLay.contents = (__bridgeID_nullable) ([UIImage imagenamed:@"111"]. Cgimage);
Calayerd animations (use Catransform3d, usually do not animate this method)
1 //Rotary Rotation2[UIView animatewithduration:0.3animations:^{3_layer.transform = Catransform3dmakerotation (M_pi_4,0,0,0);4 5 //KVC6[_layer setvalue:[nsvalue valuewithcatransform3d:catransform3dmakerotation (M_pi_4,0,0,0)] Forkeypath:@"Transform"];7 8 //KVC transform.rotation9[_layer setValue: @M_PI forkeypath:@"transform.rotation"];Ten One }]; A - //Zoom to zoom out scale -[UIView animatewithduration:0.3animations:^{ the -_layer.transform = Catransform3dmakescale (0,0,0); - - //KVC +[_layer Setvalue:[nsvalue Valuewithcatransform3d:catransform3dmakescale (0,0,0)] Forkeypath:@"Transform"]; - }]; + A //Pan translation at[UIView animatewithduration:0.3animations:^{ - -_layer.transform = Catransform3dmaketranslation (0,0,0); - - //KVC -[_layer Setvalue:[nsvalue Valuewithcatransform3d:catransform3dmaketranslation (0,0,0)] Forkeypath:@"Transform"]; in -[_layer Setvalue:[nsvalue Valuewithcatransform3d:catransform3dmaketranslation (0,0,0)] Forkeypath:@"transform.x"]; to + }]; - the // ... Catransform3dmakeaffinetransform *[UIView animatewithduration:0.3animations:^{ $ Panax Notoginseng_layer.transform = Catransform3dmakeaffinetransform (Cgaffinetransformmake (0,0,0,0,0,0)); - the //KVC +[_layer setvalue:[nsvalue Valuewithcatransform3d:catransform3dmakeaffinetransform (CGAffineTransformMake (0,0,0,0,0,0)] Forkeypath:@"Transform"]; A}];
IOS Animation Preliminary