【问题标题】:UIView layer problemsUIView层问题
【发布时间】:2011-08-23 21:59:45
【问题描述】:

我的 UIViews 有问题,我有一个框架为 240*320 的白色 UIView,以及一个框架为 480*20 的黑色 UIView,我将白色视图添加到我的 480*320 横向主视图中,然后我将黑色视图添加到白色视图中,黑色视图不仅在白色视图之上,而且在mainView之上,我不想在mainView之上,有人知道解决方案吗?,这是代码:


    UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 240, 320)];
    UIView *otherView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 20)];
    [aView setBackgroundColor:[UIColor whiteColor]];
    [otherView setBackgroundColor:[UIColor blackColor]];
    [aView addSubview:otherView];
    [[self view] addSubview:aView];

【问题讨论】:

    标签: objective-c cocoa-touch xcode ios uiview


    【解决方案1】:

    这个呢:

    aView.clipsToBounds = YES;
    

    【讨论】:

      【解决方案2】:

      用这个东西来管理视图。

      [self.view 将subviewtofront:uiview]; 并且还使用 [self.view bringsubviewtoback:uiview];

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-07-18
        • 2011-04-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-24
        • 1970-01-01
        相关资源
        最近更新 更多