Look at the film first.
Analysis steps:
1. Draw a square layer first, if:
The code is as follows:
Cagradientlayer *colorlayer =[Cagradientlayer layer]; Colorlayer.backgroundcolor=[Uicolor Bluecolor]. Cgcolor; Colorlayer.frame= (CGRect) {Cgpointzero, Cgsizemake ( $, $)}; Colorlayer.position=Self.view.center; [Self.view.layer Addsublayer:colorlayer]; //Color DistributionColorlayer.colors = @[(__bridgeID) [Uicolor Redcolor]. Cgcolor, (__bridgeID) [Uicolor Whitecolor]. Cgcolor, (__bridgeID) [Uicolor Redcolor]. Cgcolor]; //The starting position is set to beyond the interface so the default is no effectColorlayer.locations = @[@ (-0.2), @(-0.1), @(0)]; //starting pointColorlayer.startpoint = Cgpointmake (0,0); //End PointColorlayer.endpoint = Cgpointmake (1,0);
2. Set the grating slide effect
The code is as follows:
cabasicanimation* Fadeanim = [cabasicanimation animationwithkeypath:@ " Span style= "COLOR: #800000" >locations " ]; // start position left outside fadeanim.fromvalue = @[ @ (-0.2 ) @ (-0.1 ), @ ( 0 // end position right outside Fadeanim.tovalue = @[@ ( 1.0 ) @ (1.1 ), @ ( 1.2 = 1.5 ; [Colorlayer Addanimation:fadeanim Forkey:nil];
3. Set the mask mask for the layer to show only the circles
uibezierpath* Bezierpath = [Uibezierpath bezierpathwitharccenter:cgpointmake (0,0) Radius: theStartangle:degrees (0) Endangle:degrees ( the) Clockwise:yes]; Cashapelayer*layer =[Cashapelayer layer]; Layer.path=Bezierpath.cgpath; //locationLayer.position = Cgpointmake (102, -); //fill color is transparentLayer.fillcolor =[Uicolor Clearcolor]. Cgcolor; //border color is redLayer.strokecolor =[Uicolor Redcolor]. Cgcolor; //set the matte, which displays the contents of the matteColorlayer.mask = layer;
This completes the final effect.
iOS animations use Cagradientlayer for animations