1-(void) DrawRect: (cgrect) Rect2 {3 [[Uicolor Clearcolor]setfill];4 Uirectfill (rect);5Nsinteger Pulsingcount =3;6 DoubleAnimationduration =2;7 8Calayer * Animationlayer =[[Calayer alloc]init];9Self.animationlayer =Animationlayer;Ten One for(inti =0; i < Pulsingcount; i++) { ACalayer * Pulsinglayer =[[Calayer alloc]init]; -Pulsinglayer.frame = CGRectMake (0,0, Rect.size.width, rect.size.height); -Pulsinglayer.backgroundcolor = [Uicolor colorwithred:92.0/255.0Green181.0/255.0Blue217.0/255.0Alpha1.0]. Cgcolor; thePulsinglayer.bordercolor = [Uicolor colorwithred:92.0/255.0Green181.0/255.0Blue217.0/255.0Alpha1.0]. Cgcolor; -Pulsinglayer.borderwidth =1.0; -Pulsinglayer.cornerradius = rect.size.height/2; - +Camediatimingfunction * Defaultcurve =[Camediatimingfunction functionwithname:kcamediatimingfunctionlinear]; - +Caanimationgroup * Animationgroup =[[Caanimationgroup alloc]init]; AAnimationgroup.fillmode =Kcafillmodeboth; atAnimationgroup.begintime = Cacurrentmediatime () + (Double) I * animationduration/(Double) Pulsingcount; -Animationgroup.duration = animationduration; Animationgroup.repeatcount =Huge_val; -Animationgroup.timingfunction =Defaultcurve; - -Cabasicanimation * scaleanimation = [cabasicanimation animationwithkeypath:@"Transform.scale"]; -Scaleanimation.autoreverses =NO; inScaleanimation.fromvalue = [NSNumber numberwithdouble:0.2]; -Scaleanimation.tovalue = [NSNumber numberwithdouble:1.0]; to +Cakeyframeanimation * opacityanimation = [cakeyframeanimation animationwithkeypath:@"Opacity"]; -Opacityanimation.values = @[[nsnumber numberwithdouble:1.0],[nsnumber numberwithdouble:0.5],[nsnumber numberwithdouble:0.3],[nsnumber numberwithdouble:0.0]]; theOpacityanimation.keytimes = @[[nsnumber numberwithdouble:0.0],[nsnumber numberwithdouble:0.25],[nsnumber numberwithdouble:0.5],[nsnumber numberwithdouble:1.0]]; *Animationgroup.animations =@[scaleanimation,opacityanimation]; $ Panax Notoginseng[Pulsinglayer addanimation:animationgroup Forkey:@"pulsing"]; - [Animationlayer Addsublayer:pulsinglayer]; the } +Self.animationLayer.zPosition =-1;//when reloading, make the animation to the bottom A [Self.layer AddSublayer:self.animationLayer]; the +Calayer * Thumbnaillayer =[[Calayer alloc]init]; -Thumbnaillayer.backgroundcolor =[Uicolor Whitecolor]. Cgcolor; $CGRect Thumbnailrect = CGRectMake (0,0, $, $); $thumbnailrect.origin.x = (rect.size.width-thumbnailrect.size.width)/2.0; -THUMBNAILRECT.ORIGIN.Y = (rect.size.height-thumbnailrect.size.height)/2.0; -Thumbnaillayer.frame =Thumbnailrect; theThumbnaillayer.cornerradius =23.0; -Thumbnaillayer.borderwidth =1.0;WuyiThumbnaillayer.maskstobounds =YES; theThumbnaillayer.bordercolor =[Uicolor Whitecolor]. Cgcolor; -UIImage * thumbnail =Self.thumbnailimage; WuThumbnaillayer.contents = (ID) thumbnail. Cgimage; -Thumbnaillayer.zposition =-1; About [Self.layer Addsublayer:thumbnaillayer]; $}
IOS implements the core code for radar-like effects