【问题标题】:iOS >> Quart Core 'Corner Radius' Doesn't Affect Navigation Bar in Custom ViewiOS >> Quart Core 'Corner Radius' 不影响自定义视图中的导航栏
【发布时间】:2014-10-03 09:10:25
【问题描述】:

我有一个自定义视图(继承 UIView);我正在尝试将其内容视图的角弄圆。 我正在使用 QuartzCore 相关属性来执行此操作。在内容视图的顶部,有一个导航栏,我似乎无法嵌入这些“圆角”效果。

代码如下:

    - (void)drawRect:(CGRect)rect
{
    self.contentView.layer.borderWidth = 2;
    self.contentView.layer.borderColor = [UIColor blueColor].CGColor;
    self.contentView.layer.cornerRadius = 8;

    self.navBar.layer.cornerRadius = 8;
}

如何使导航栏的角也变圆?

【问题讨论】:

    标签: ios uinavigationbar custom-view quartz-core


    【解决方案1】:

    我可以通过添加达到你想要的效果

    self.navBar.clipsToBounds = YES;
    

    【讨论】:

      【解决方案2】:

      用这些行替换您的代码。

      - (void)drawRect:(CGRect)rect{
      self.contentView.layer.borderWidth = 2;
      self.contentView.layer.borderColor = [UIColor blueColor].CGColor;
      self.contentView.layer.cornerRadius = 8;
      self.contentView.masksToBounds = YES;
      

      }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-12
        • 2015-03-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多