您可以发布动画块和其他相关代码吗?我不确定CGAffineTransformMakeTranslation
标签有什么作用,但如果你想为框架位置设置动画,你可以使用这个:
CGRect frame = _nameLabel.frame;
frame.origin.y = 100; //Desired height, origin.x can be modified as well.
//You can also change the frame size here but it wont work on UILabels, you will need `CGAffineTransformScale` for that.
[UIView animateWithDuration: 1.5
delay:0.0
options:UIViewAnimationCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState
animations:^ {
[_nameLabel setFrame:frame];
}
completion:^ (BOOL finished) {
}];
编辑:另一种方式:
CGRect frame = _nameLabel.frame;
frame.origin.y = 100;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.5];
[_nameLabel setFrame: newFrame];
[UIView commitAnimations];
当前状态可能是标签的当前位置,请先尝试,但如果没有任何反应,UIViewAnimationOptionBeginFromCurrentState
请在动画之前将标签的框架移除或设置到另一个位置,并将其移动到其初始(xib 文件中的那个)位置动画块,由您决定。