Reputation: 7072
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.
I already set these properties on the viewDidLoad
:
progressView.clipsToBounds = true
progressView.layer.cornerRadius = 3
progressView.layer.masksToBounds = true
Upvotes: 1
Views: 1257
Reputation: 7648
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
Upvotes: 0
Reputation: 16160
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;
}];
Upvotes: -1
Reputation: 5588
I think you should search into the sublayer to find de blue one and apply the same treatment
Upvotes: 5