ios - UIButton animation not working properly -


see commented code below. why uibutton act differently uiview?

//button creation uibutton *mybtn = [uibutton buttonwithtype:uibuttontypecustom]; [mybtn setimage:[uiimage imagenamed:@"someimage"] forstate:uicontrolstatenormal]; self.mybutton = mybtn;  ... ///in button target method:  uiview* test = [[uiview alloc] initwithframe:self.mybutton.frame]; test.backgroundcolor = [uicolor redcolor]; [buttoncontainer addsubview:test];  [uiview beginanimations:@"someanimation" context:nil]; [uiview setanimationduration:5]; [uiview setanimationdelegate:self]; self.mybutton.frame = cgrectmake(100,100,200,200); //the position animates smoothly, size snaps 200,200 //test.frame = cgrectmake(100,100,200,200); //this works perfectly. position , size both animate smoothly on 5 seconds. [uiview commitanimations]; 

@implementation uibutton(fixresizeanimation)  - (void)setframe:(cgrect)_frame {   [super setframe:_frame];   for(uiview* v in self.subviews) {     if([v iskindofclass:[uiimageview class]]) {       [v setframe:_frame];     }   } }  @end 

please try!


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -