最近UIViews
、IBOutlet
. コードでビューをインスタンス化してからアニメーション化すると、すべてが正常に機能します。IBOutlet
ただし、ストーリーボードで作成され、アニメーションなしで割り当てられた場合、機能しません。足りないものはありますか?
@property (nonatomic, strong) IBOutlet UIView *foreground;
アニメーションブロックを使用しています
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
NSLog(@"oldForegroundFrame %@, newForeGroundFrame: %@", NSStringFromCGRect(self.foreground.frame), NSStringFromCGRect(foregroundFrame));
self.foreground.frame = foregroundFrame;
NSLog(@"oldForegroundFrame %@, newForeGroundFrame: %@", NSStringFromCGRect(self.foreground.frame), NSStringFromCGRect(foregroundFrame));
} completion:^(BOOL finished) {
NSLog(@"oldForegroundFrame %@, newForeGroundFrame: %@", NSStringFromCGRect(self.foreground.frame), NSStringFromCGRect(foregroundFrame));
}];
NSLog からの出力は、割り当て後にフレームが正しく設定されていることを示していますが、完了すると元の位置にリセットされています。
oldForegroundFrame {{0, 0}, {320, 133}}, newForeGroundFrame: {{0, -45}, {320, 45}} oldForegroundFrame {{0, -45}, {320, 45}}, newForeGroundFrame: { {0, -45}, {320, 45}} oldForegroundFrame {{0, 0}, {320, 133}}, newForeGroundFrame: {{0, -45}, {320, 45}}