我有一個進度視圖,我看到,如果我改變它的圓角半徑,當進度爲1.0(完整)時,我會得到圓角,但是,我希望整個圓角都有圓角例如,下面的圖片顯示了一半的進展情況,因爲您可以看到只有左端有圓角。整個過程中的圓角
我已經在viewDidLoad
設置這些屬性:
progressView.clipsToBounds = true
progressView.layer.cornerRadius = 3
progressView.layer.masksToBounds = true
我有一個進度視圖,我看到,如果我改變它的圓角半徑,當進度爲1.0(完整)時,我會得到圓角,但是,我希望整個圓角都有圓角例如,下面的圖片顯示了一半的進展情況,因爲您可以看到只有左端有圓角。整個過程中的圓角
我已經在viewDidLoad
設置這些屬性:
progressView.clipsToBounds = true
progressView.layer.cornerRadius = 3
progressView.layer.masksToBounds = true
我想你應該尋找到底層找到德藍色和應用相同的處理
對於任何人在未來尋找正確的方式來訪問它,這工作對我來說:'barLayer = progressView.layer.sublayers [1]'。然後根據需要調整「cornerRadius」和「masksToBounds」屬性。 – tfe
是,@ CZ54的回答是正確的。這是守則。
[progressView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
obj.layer.masksToBounds = YES;
obj.layer.cornerRadius = progressView.layer.cornerRadius;
}];
這是正確的答案
// 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
我想你應該尋找到底層找到德藍色和應用相同的處理 – CZ54
退房的對象 - 這類似的問題:HTTP:/ /stackoverflow.com/q/14775310/1689376 – alexburtnik
@bobby誠然,我做了子視圖,並沒有工作。現在你談到了我試過的子層,並且它工作。把它作爲答案,我將它標記爲正確的。 –