First step: Create a view to add this view to the current controller
Such as:
CGFloat Timew =* Timean = [[timeanimation alloc]initwithframe:cgrectmake (0,0, Timew, Timew)]; = Cgpointmake (self.view.bounds.size.width*0.5, self.view.bounds.size.height *0.5); [ Self.view Addsubview:timean];
Step Two: Add the following code to the view's. m file
#define PI 3.14159265358979323846
#define Kradius self.bounds.size.width*0.1
-(Instancetype) initWithFrame: (cgrect) frame{if(self =[Super Initwithframe:frame]) {Self.frame=frame; Self.backgroundcolor=[Uicolor Clearcolor]; } returnSelf ;}- (void) DrawRect: (cgrect) Rect {cgcontextref context=Uigraphicsgetcurrentcontext (); [Self greenround:context]; Self.alpha=0.5; [Self test];}-(void) test{//2. Create a scaled animation objectCabasicanimation *scale =[cabasicanimation animation]; Scale.keypath=@"Transform.scale"; Scale.fromvalue=[nsnumber numberwithfloat:0.0]; Scale.tovalue=[nsnumber numberwithfloat:1.0]; Cabasicanimation*scale1 =[cabasicanimation animation]; Scale1.keypath=@"Opacity"; Scale1.fromvalue=[nsnumber numberwithfloat:1.0]; Scale1.tovalue=[nsnumber numberwithfloat:0.0]; //4. Add all animations to the animation groupCaanimationgroup *group =[Caanimationgroup animation]; Group.animations=@[scale,scale1]; Group.duration=.6; Group.repeatcount=huge_valf; Group.removedoncompletion=NO; Group.fillmode=kcafillmodeforwards; [Self.layer Addanimation:group forkey:nil];}/** Draw a green circle*/-(void) Greenround: (cgcontextref) context{cgcontextsetrgbstrokecolor (context, -/255.0,177/255.0, the/255.0,1);//Color of brush linesCgcontextsetlinewidth (Context,4.0);//the width of the line//x, y is the dot coordinate, radius radius, startangle is the starting Radian, Endangle is the ending Radian, clockwise 0 is clockwise, and 1 is counterclockwise. Cgcontextaddarc (Context, Self.bounds.size.width *0.5, self.bounds.size.height*0.5, self.bounds.size.width*0.21,0,2*PI,0);//Add a circleCgcontextdrawpath (context, kcgpathstroke);//Draw Path}
IOS Circle's Zoom animation effect