无法为IBOutlet分配的视图设置动画

时间:2013-06-20 09:18:40

标签: animation uiview uistoryboard iboutlet

最近,我遇到了通过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}}

0 个答案:

没有答案