Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel change height, animation expands from center

I'm trying to increase a labels height using animation, however the animation causes the label to first expand from the center, and then jump in place with the correct y point. This looks terrible. I would like only the bottom to expand.

[UIView animateWithDuration:0.5 delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{

   [self.about increaseHeightFromTopLeft:deltaHeight];

   [self.scrollView increaseContentHeight];

} completion:nil];


- (void)increaseHeightFromTopLeft:(CGFloat ) increased  {

    CGRect newFrame = CGRectMake(self.originX, self.originY, self.frameWidth, self.frameHeight + increased);

    self.frame = newFrame;
}

The label is called about, you can see a video of the animation here. https://www.youtube.com/watch?v=DcqktIZ9moY&feature=youtu.be

like image 730
Tommy Sadiq Hinrichsen Avatar asked Sep 22 '14 20:09

Tommy Sadiq Hinrichsen


1 Answers

Faced same problem! Try to set label' contentMode to Top in code:

label.contentMode = UIViewContentModeTop;
like image 103
Alexander Larionov Avatar answered Sep 30 '22 21:09

Alexander Larionov