我正在制作一个动画,我必须在其中制作一个名为“subView”的 UIView
的高度为 0。
现在 subview 包含一个 UIButton
和 UIImageView
。
现在我在点击按钮时通过这种方法使高度为 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
但是当我将高度设置为 0 时,名为“subButton”和“imgview”的 View 看起来是这样的。 我想让它们在 subView 高度为 0 时隐藏。
我正在使用 XCode 4.5
最佳答案
如果你想在不调整大小的情况下隐藏它们:[mainview setClipsToBounds:YES]
关于iphone - 隐藏所有包含的 View 通过使父 UiView 的高度为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12892100/