title: How to change CAShapeLayer alpha/opacity value?
body: <p>I can't seem to change the opacity of my <code>CAShapeLayer</code> whatever I do. I tried setting the opacity:</p>
  
  <pre><code>    bottomProgressBar.strokeColor = UIColor.white.cgColor
      bottomProgressBar.opacity = 0.1
  </code></pre>
  
  <p>Didn't work. Then I tried this:</p>
  
  <pre><code>bottomProgressBar.strokeColor = UIColor(displayP3Red: 255, green: 255, blue: 255, alpha: 0.1).cgColor
  </code></pre>
  
  <p>In both cases the alpha value is 1.<br>
  Is there another way to do this ? Or am I setting them wrong ?</p>
  
  <p>edit:</p>
  
  <p>Here is my code:<br>
  This is a class inheriting from <code>UIView</code>:</p>
  
  <pre><code>override init(frame: CGRect) {
      super.init(frame: frame)
      configure()
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      configure()
  }
  
  func configure() {
      bottomProgressBar.strokeColor = UIColor.white.cgColor
      bottomProgressBar.opacity = 0.1
      bottomProgressBar.lineWidth = self.frame.height
      bottomProgressBar.strokeStart = 0
      bottomProgressBar.strokeEnd = 1
      self.layer.addSublayer(bottomProgressBar)
  
      topProgressBar.strokeColor = UIColor.white.cgColor
      topProgressBar.lineWidth = self.frame.height
      topProgressBar.strokeStart = 0
      topProgressBar.strokeEnd = 1
      self.layer.addSublayer(topProgressBar)
  }
  </code></pre>
  
  <p>edit 2:</p>
  
  <pre><code>override func layoutSubviews() {
      super.layoutSubviews()
  
      let path = UIBezierPath()
      path.move(to: CGPoint(x: 0, y: 0))
      path.addLine(to: CGPoint(x: self.frame.width, y: 0))
  
      bottomProgressBar.path = path.cgPath
      topProgressBar.path = path.cgPath
  }
  </code></pre>
  
  <p>edit 3:</p>
  
  <p><a href="https://i.stack.imgur.com/CE6ha.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CE6ha.jpg" alt="enter image description here"></a></p>