ios - uilabel animating to original position -


i'm trying animate uilabel frame position in middle of screen. instead, seems animating somewhere outside view original position.

[uiview beginanimations:@"labelanim" context:nil]; [uiview setanimationbeginsfromcurrentstate:yes]; [uiview setanimationcurve: uiviewanimationcurveeasein]; [uiview setanimationduration:1.0]; [self.scorelabel setframe:self.endscoreframe]; [uiview commitanimations]; 

here starting , ending frames:

start frame: {{10, 30}, {144, 21}} final frame: {{93.75, 158.71438598632812}, {187.5, 46.875}} 

try code

[uiview animatewithduration:1.0                           delay:0.0                         options:uiviewanimationcurveeasein | uiviewanimationoptionbeginfromcurrentstate                      animations:^{                          [self.scorelabel setframe:self.endscoreframe];                      } completion:^(bool finished) {                          nslog("completed");                      }]; 

and make sure endscoreframe have correct new position coordinates:

  nslog(@"%@", nsstringfromcgrect(self.endscoreframe));  

i have tested code values of old , new frames , works fine:

@property (nonatomic, strong) uilabel *lbl; 

viewdidload:

self.lbl = [[uilabel alloc] initwithframe:cgrectmake(10, 30, 144, 21)]; self.lbl.text = @"mylabel";  [self.view addsubview:self.lbl] ; 

action

-(void)btnclick:(id)sender {       cgrect newframe = cgrectmake(93.75, 158.71438598632812, 187.5, 46.875);       [uiview animatewithduration:1.0                           delay:0.0                         options:uiviewanimationcurveeasein | uiviewanimationoptionbeginfromcurrentstate                      animations:^{                          self.lbl.frame = newframe ;                      } completion:^(bool finished) {                       }];  } 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -