【问题标题】:Rounded corner throughout the whole progress圆角贯穿整个进度
【发布时间】:2016-11-09 15:48:57
【问题描述】:

我有一个进度视图,我看到如果我改变它的圆角半径,当进度为 1.0(完整)时,我会得到圆角,但是,我希望在整个进度中都有圆角,例如,下图显示了一半的进度,您可以看到只有左端有圆角。

我已经在viewDidLoad上设置了这些属性:

progressView.clipsToBounds = true
progressView.layer.cornerRadius = 3
progressView.layer.masksToBounds = true

【问题讨论】:

  • 我认为您应该搜索子层以找到 de blue 并应用相同的处理
  • 在 Obj-C 中查看类似的问题:stackoverflow.com/q/14775310/1689376
  • @bobby 确实,我使用了子视图但没有工作。既然你谈到了我尝试过的子层,它就奏效了。将其作为答案,我会将其标记为正确的。
  • @HolaSoyEduFelizNavidad 完成:D thx

标签: ios uikit swift3


【解决方案1】:

我认为您应该搜索子层以找到 de blue 并应用相同的处理

【讨论】:

  • 对于将来寻找正确访问方式的任何人,这对我有用:barLayer = progressView.layer.sublayers[1]。然后根据需要调整它的cornerRadiusmasksToBounds属性。
【解决方案2】:

这是正确答案

// Set the rounded edge for the outer bar
self.layer.cornerRadius = 12
self.clipsToBounds = true

// Set the rounded edge for the inner bar        
self.layer.sublayers![1].cornerRadius = 12
self.subviews[1].clipsToBounds = true

【讨论】:

    【解决方案3】:

    是的,@CZ54 的回答是正确的。这是代码。

    [progressView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            obj.layer.masksToBounds = YES;
            obj.layer.cornerRadius = progressView.layer.cornerRadius;
        }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 1970-01-01
      • 2012-09-27
      • 2015-11-28
      • 1970-01-01
      相关资源
      最近更新 更多