最近我遇到了一个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}}