2

Currently, I am working with UIProgressView where I need to change the height of the UIProgressView. I achieve through below code.

extension UIProgressView {

@IBInspectable var barHeight : CGFloat {
    get {
        return transform.d * 2.0
    }
    set {
        // 2.0 Refers to the default height of 2
        let heightScale = newValue / 2.0
        let c = center
        transform = CGAffineTransform(scaleX: 1.0, y: heightScale)
        center = c

        self.layer.cornerRadius = 20.0

    }
  }
}

but when I set cornerRadius to UIProgressView not get affected.

Dark Innocence
  • 1,389
  • 9
  • 17
Kushal Maniyar
  • 846
  • 1
  • 8
  • 26

1 Answers1

0

You also need to tell that to not draw outside its bounds, after setting the cornerRadius.

//this is on the layer level

self.progressView.layer.masksToBounds = true

//another way is to use clipToBounds
self.progressView.clipsToBounds = true
Dark Innocence
  • 1,389
  • 9
  • 17