objective c - how can i create a pulsating animation for UIButton iOS? -


iam trying create pulsating animation uibutton these codes far ,but still not able exact animation shown in link

css pulsating button

my code

 uibutton *button = [uibutton buttonwithtype:uibuttontyperoundedrect];     button.backgroundcolor = [uicolor lightgraycolor];     [button settitlecolor:[uicolor whitecolor] forstate:uicontrolstatenormal];        [button addtarget:self                action:@selector(method)      forcontrolevents:uicontroleventtouchupinside];     [button settitle:@"show view" forstate:uicontrolstatenormal];     button.frame = cgrectmake(80.0, 210.0, 160.0, 160.0);     cabasicanimation *pulseanimation = [cabasicanimation animationwithkeypath:@"transform.scale"];     pulseanimation.duration = .5;     pulseanimation.tovalue = [nsnumber numberwithfloat:1.1];     pulseanimation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout];     pulseanimation.autoreverses = yes;     pulseanimation.repeatcount = flt_max;     [button.layer addanimation:pulseanimation forkey:nil];     button.layer.cornerradius=button.frame.size.width / 2;     ;     button.layer.maskstobounds = yes;      [self.view addsubview:button]; 

try this.

uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; button.frame = cgrectmake(0, 0, 100, 100); button.center = self.view.center; [button settitle:@"button" forstate:uicontrolstatenormal];  uiview *c = [[uiview alloc] initwithframe:button.bounds]; c.backgroundcolor = [uicolor bluecolor]; c.layer.cornerradius = 50; [button addsubview:c]; [button sendsubviewtoback:c];  uiview *f = [[uiview alloc] initwithframe:button.bounds]; f.backgroundcolor = [[uicolor bluecolor] colorwithalphacomponent:0.3]; f.layer.cornerradius = 50; [button addsubview:f]; [button sendsubviewtoback:f];  cabasicanimation *pulseanimation = [cabasicanimation animationwithkeypath:@"transform.scale"]; pulseanimation.duration = .5; pulseanimation.tovalue = [nsnumber numberwithfloat:1.1]; pulseanimation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; pulseanimation.autoreverses = yes; pulseanimation.repeatcount = maxfloat; [c.layer addanimation:pulseanimation forkey:@"a"]; [button.titlelabel.layer addanimation:pulseanimation forkey:@"a"];  cabasicanimation *fade = [cabasicanimation animationwithkeypath:@"opacity"]; fade.tovalue = @0; cabasicanimation *pulse = [cabasicanimation animationwithkeypath:@"transform.scale"]; pulse.tovalue = @2; caanimationgroup *group = [caanimationgroup animation]; group.animations = @[fade,pulse]; group.duration = 1.0; group.repeatcount = maxfloat; [f.layer addanimation:group forkey:@"g"];  [self.view addsubview:button]; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -