iphone - 隐藏所有包含的 View 通过使父 UiView 的高度为 0

标签 iphone ios xcode ios4 ios6

我正在制作一个动画,我必须在其中制作一个名为“subView”的 UIView 的高度为 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

但是当我将高度设置为 0 时,名为“subButton”和“imgview”的 View 看起来是这样的。 我想让它们在 subView 高度为 0 时隐藏。

我正在使用 XCode 4.5

最佳答案

如果你想在不调整大小的情况下隐藏它们:[mainview setClipsToBounds:YES]

关于iphone - 隐藏所有包含的 View 通过使父 UiView 的高度为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12892100/

相关文章:

swift - 添加导航项会缩小 View 中的所有内容

ios - 因 NSException 类型的未捕获异常而终止 Timer Swift 崩溃

iphone - 分组 UITableView 中节标题和第一个单元格之间的透明像素行

iphone - ios我可以从不同的线程观察者(NSNotificationCenter)

ios - 添加一个以 UIImageView 为中心的 CALayer 子层

ios - xcode9 - ionic3 项目中出现代码签名错误,命令/usr/bin/codesign 失败,退出代码为 1

ios - iPhone 应用程序被拒绝,原因 : App name to be displayed on the App Store does not sufficiently match the name of the app displayed on a device

c++ - xcode 解决方案的 node-gyp 链接问题

iphone - 在 didSelectRowAtIndexPath 中的单元格上找到一个确切的 UIImageView

ios - 不允许用户在 UITextField 中输入数字 1 作为第一位数字