【问题标题】:issue: subview becoms on top of superview when it moves out of the superview问题:当子视图移出超级视图时,子视图位于超级视图之上
【发布时间】:2011-11-22 09:14:56
【问题描述】:

这里有两个组件,UIView *superView 和 UILabel *label。 label 是 superView 的子视图。问题是当我将标签移出超级视图时,标签将位于超级视图的顶部。如果标签超出其超级视图的框架,标签是否不可见?

谢谢!

【问题讨论】:

    标签: iphone ios uiview subview


    【解决方案1】:

    UIView 有一个属性clipsToBounds。将其设置为 YES 为您的 superView 将使所有超出其边界的视图都被剪裁。

    【讨论】:

      【解决方案2】:

      我希望您已将您的标签与您的 IB 相关联,并在声明您的 UILabel 时使用了 IBOutlet。 IE 在 .h 文件中

           IBOutlet UILabel *myLabel;
      

      将 myLabel 与您在 IB 中创建的标签链接。 如果你这样做了

      只需使用 [myLabel removeFromSuperview];

      它会起作用的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-29
        • 1970-01-01
        • 1970-01-01
        • 2016-10-12
        • 2012-11-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多