ios - How to change the rectangle shape to a circle shape with animation -


i have label:

    self.loginlabel = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 300, 100)];     self.loginlabel.backgroundcolor = [uicolor clearcolor];     self.loginlabel.backgroundcolor = color_circle_outer;     self.loginlabel.textcolor = color_circle_outer;     self.loginlabel.textalignment = nstextalignmentcenter;     self.loginlabel.linebreakmode = nslinebreakbywordwrapping;     self.loginlabel.numberoflines = 1;     self.loginlabel.font = [uifont boldsystemfontofsize:12*ipad];     self.loginlabel.text = @"log in";     [self addsubview:self.loginlabel];     self.loginlabel.layer.cornerradius   = self.frame.size.height/2.0;     self.loginlabel.layer.bordercolor    = color_circle_outer.cgcolor;     self.loginlabel.layer.borderwidth    = 2*ipad;     self.loginlabel.layer.maskstobounds  = yes; 

i want change shape circle. have tried:

    [uiview animatewithduration:animationtime animations:^{        self.loginlabel.layer.bounds = cgrectmake(0, 0, self.frame.size.height, self.frame.size.height);     }]; 

but shape changed without animation, position change center animation. tried this:

    [uiview animatewithduration:animationtime animations:^{        self.loginlabel.bounds = cgrectmake(0, 0, self.loginlabel.frame.size.height, self.loginlabel.frame.size.height);     }]; 

i have ugly animation effect.

i not care if view label, want implement changing rectangle shape circle shape animation.

thank you.

from code remove line :

self.loginlabel.layer.cornerradius = self.loginlabel.frame.size.height / 2.0; 

and put in animation block this

you can set cornerradius of uilabel circular view.

[uiview animatewithduration:animationtime animations:^{        self.loginlabel.layer.cornerradius = self.loginlabel.frame.size.height / 2.0f;     }]; 

however, animation not , final frame not exact circle because height , width of uilabel not in 1:1 proportion.

if still don't animation try check value of animationtime variable.


Comments