隐藏包含By的所有视图使父UiView的高度为0

Vis*_*hal 2 iphone xcode ios4 ios ios6

我正在制作一个动画,在其中我必须使一个UIView名为" subView "的高度为0 .现在,subView包含一个UIButtonUIImageView.现在我通过按钮点击这个方法使高度为0

@interface ViewController : UIViewController
{
    IBOutlet UIView *suvView;
    IBOutlet UIButton *subButton;
    IBOutlet UIImageView *imgview;
}
-(IBAction)hide:(id)sender;
@end


@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self.view addSubview:suvView];
    [suvView addSubview:subButton];
    [suvView addSubview:imgview];
}

-(IBAction)hide:(id)sender
{
    [UIView beginAnimations:nil context:suvView];
    [UIView setAnimationDuration:0.25];
    [suvView setFrame:CGRectMake(0, 94, 320, 0)];
    [UIView commitAnimations];
}
@end
Run Code Online (Sandbox Code Playgroud)

但是当我使高度为0而不是名为"subButton"的视图时,"imgview"看起来就像它一样.我想在subView高度为0时隐藏它.

我正在使用XCode 4.5

Jon*_*hon 6

如果你想隐藏它们而不调整大小: [mainview setClipsToBounds:YES]