2016-11-09 23 views
1

我有一個進度視圖,我看到,如果我改變它的圓角半徑,當進度爲1.0(完整)時,我會得到圓角,但是,我希望整個圓角都有圓角例如,下面的圖片顯示了一半的進展情況,因爲您可以看到只有左端有圓角。整個過程中的圓角

Progres (=========

我已經在viewDidLoad設置這些屬性:

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

我想你應該尋找到底層找到德藍色和應用相同的處理 – CZ54

+0

退房的對象 - 這類似的問題:HTTP:/ /stackoverflow.com/q/14775310/1689376 – alexburtnik

+0

@bobby誠然,我做了子視圖,並沒有工作。現在你談到了我試過的子層,並且它工作。把它作爲答案,我將它標記爲正確的。 –

回答

4

我想你應該尋找到底層找到德藍色和應用相同的處理

+2

對於任何人在未來尋找正確的方式來訪問它,這工作對我來說:'barLayer = progressView.layer.sublayers [1]'。然後根據需要調整「cornerRadius」和「masksToBounds」屬性。 – tfe

-1

是,@ CZ54的回答是正確的。這是守則。

[progressView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 
     obj.layer.masksToBounds = YES; 
     obj.layer.cornerRadius = progressView.layer.cornerRadius; 
    }]; 
0

這是正確的答案

// 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