アニメーション ブロックとその他の関連コードを投稿できますか? ラベルがどうなるかはわかりません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 ファイル内の位置) に移動します。アニメーション ブロック、それはあなたの呼び出しです。