如何在iOS中删除带幻灯片的SubView?

时间:2012-07-07 11:40:56

标签: ios uiview

我尝试在代码后添加带动画的SubView。没关系。

[self.view addSubview:pickerView];
    pickerView.frame = CGRectMake(0, 0, 320, 50);
    [UIView animateWithDuration:1.0 
                     animations:^{
                         pickerView.frame = CGRectMake(0, 152, 320, 260);
                     }];

我还想删除带有上述动画的幻灯片动画的子视图。

我该怎么做?

提前致谢。

2 个答案:

答案 0 :(得分:9)

您可以使用此animateWithDuration完成块来删除视图

[UIView animateWithDuration:1.0 
                 animations:^{
                     pickerView.frame = //move it out of screen
                 } completion:^(BOOL finished) {
                     [pickerView removeFromSuperView];
                 }];

答案 1 :(得分:3)

[UIView animateWithDuration:.2 animations:^{
         pickerView.frame = CGRectMake(0, 0, 320, 50);   

        } completion:^(BOOL finished){
            [pickerView removeFromSuperView];          
        }];