2014-02-06 52 views
0

我有自定義UICollectionViewCell,並且我已將2 UILabels放入其中。現在我想更改其中的標籤borderRadiusborderWidth。誰能告訴我如何做到這一點? 我做這種方式,但什麼也沒發生:更改自定義UICollectionCell中標籤的邊框寬度

self.titleLabel.layer.borderWidth = 2.0; 
    self.titleLabel.layer.borderColor = [UIColor blackColor].CGColor; 

我在initWithFrame方法把這些兩行。

+0

是否確定,'self.titleLabel'不回零? –

+0

你記得'#import '並鏈接到它嗎? – Gad

+0

@ValentinShamardin yes –

回答

0

如果你想設置的UILabel的邊框寬度內意味着你爲什麼要使用

self.titleLabel.layer.borderWidth = 2.0; 

取而代之的是,你可以直接使用的標籤名稱一樣,

yourLabel1.layer.borderWidth = 2.0; 
yourLabel2.layer.borderWidth = 2.0; 

喜歡聰明人,你可以改變borderRadius也。

0

通過下面的一行添加邊框應顯示:

self.titleLabel.layer.masksToBounds = YES;