Change size of label's frame with animation

2019-06-11 08:53发布

I would like to know if there is a way to change a label's frame's width (not the fontSize or something) with a smooth animation.

I already tried the following, that did (obviously) not work:

_myLabel.frame = CGRectMake(139,193,42,21);

[UIView animateWithDuration:1 animations:^ {
    _myLabel.frame = CGRectMake(139, 193, 100, 21);
} completion:^(BOOL finished) {
}];

So what basically happened after running this code was that it changed the width as expected but without any animation.

Any ideas?

1条回答
一夜七次
2楼-- · 2019-06-11 09:46

You can't change the frame size of labels... You can reach correct animation behavior.. set label.contentMode = UIViewContentModeCenter but it looks ugly

But you can...:

查看更多
登录 后发表回答