【问题标题】:Swift: UIBeizerPath CAShapelayer filling when fill commentedSwift:填充注释时的 UIBeizerPath CAShapelayer 填充
【发布时间】:2016-08-17 07:06:32
【问题描述】:

我正在使用带有 roundedRect 和 CAShaplayer 的 UIBeizerPath 来附加到我的 UIView。我已经注释掉了填充,但它仍在填充矩形。

我要做的就是在外面画圆角矩形线。

我猜 roundedRect 是一个实体,我可能必须使用 UIBeizerPath 或用 clear 填充,但我找不到文档。

这是我的代码:

    let rect: CGRect = frontview.bounds
    var shape: UIBezierPath = UIBezierPath(roundedRect: rect, cornerRadius: 5.0)
    var shapeLayer = CAShapeLayer()
    shapeLayer.path = shape.CGPath
    //shapeLayer.fillColor = UIColor(red: 0.5, green: 1, blue: 0.5, alpha: 1).CGColor
    shapeLayer.strokeColor = UIColor.blackColor().CGColor
    shapeLayer.lineWidth = 2
    self.frontview.layer.addSublayer(shapeLayer)

感谢您的帮助

【问题讨论】:

    标签: ios swift uibezierpath rounded-corners cashapelayer


    【解决方案1】:

    fillColor 设置为nil

    shapeLayer.fillColor = nil
    

    【讨论】:

      【解决方案2】:

      “默认是不透明的黑色。”

      fillColor 属性的文档。

      【讨论】:

      • 错过了那个。谢谢!
      • @NicholasMuir 欢迎您。你不是第一个遇到这个问题的人。我从错误中吸取了教训:P
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多