启动后自动布局动画

时间:2014-08-07 17:31:12

标签: ios uiview autolayout

我的设计是这样的:在屏幕的下边缘有一个子视图。应用程序启动后,viewDidLayoutSubviews调用i动画从底部滑出视图。我的问题是 - 每次状态栏改变(例如接收呼叫)时,底部视图再次滑出。 这是我的代码:

        [UIView animateWithDuration:0.7 animations:^ {
            self.bottomView.frame = CGRectMake(0.0,
                                               self.view.frame.size.height - heightOfBot,
                                               self.bottomView.frame.size.width,
                                               self.bottomView.frame.size.height);

        }];

1 个答案:

答案 0 :(得分:0)

使用属性:

@property (nonatomic) BOOL bottomViewVisible;

一种方法:

- (void)showBottomView {
    if ( !self.bottomViewVisible ) {
        self.bottomViewVisible = YES;
        [UIView animateWithDuration:0.7 animations:^{
            self.bottomView.frame = CGRectMake(0.0,
                                               CGRectGetHeight(self.view.bounds) - heightOfBot,
                                               CGRectGetWidth(self.bottomView.frame),
                                               CGRectGetHeight(self.bottomView.frame));

        }];
    }
}

(我更改了您的CGRect直接会员访问权限,以便根据文档使用CGGeometry.h中的功能。)

相关问题