1

I have a progress view and I see that if I change its corner radius I get rounded corners when the progress is 1.0 (full), however, I'd like to have rounded corner throughout the whole progress, for example, the image below shows a progress on half way, as you can see only the left end has rounded corners.

Progres (=========

I already set these properties on the viewDidLoad:

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

3 Answers3

5

I think you should search into the sublayer to find de blue one and apply the same treatment

CZ54
  • 5,488
  • 1
  • 24
  • 39
  • 3
    For anyone in the future looking for the right way to access it, this worked for me: `barLayer = progressView.layer.sublayers[1]`. Then adjust the `cornerRadius` and `masksToBounds` properties of that as required. – tfe Jan 13 '17 at 08:03
0

This is the correct answer

// 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
Andrea Miotto
  • 7,084
  • 8
  • 45
  • 70
-1

Yes, @CZ54's answer is correct. Here is the Code.

[progressView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.layer.masksToBounds = YES;
        obj.layer.cornerRadius = progressView.layer.cornerRadius;
    }];
Lal Krishna
  • 15,485
  • 6
  • 64
  • 84