【发布时间】:2014-02-06 05:05:00
【问题描述】:
我有自定义UICollectionViewCell,我在其中放置了 2 个UILabels。现在我想更改其中标签的borderRadius 和borderWidth。谁能告诉我该怎么做?
我正在这样做,但什么也没发生:
self.titleLabel.layer.borderWidth = 2.0;
self.titleLabel.layer.borderColor = [UIColor blackColor].CGColor;
我将这两行放在initWithFrame 方法中。
【问题讨论】:
-
你确定,
self.titleLabel不返回 nil 吗? -
您记得
#import <QuartzCore/QuartzCore.h>并链接到它吗? -
@ValentinShamardin 是的
-
@SaurabhGulia,如果你使用xib,你为什么使用initWithFrame?尝试在
cellForItemAtIndexPath中设置边框 -
@SaurabhGulia,我在
init中添加子视图并在layoutSubviews中设置子视图的框架
标签: ios iphone objective-c uicollectionview