使用UITextView的子类更改UITextView边框颜色和Corner Radius

时间:2013-07-16 21:13:21

标签: uitextview border

我有一个UITextView,我想改变它的边框颜色和圆角。 根据{{​​3}},我可以以编程方式进行。

CALayer *imageLayer = textView.layer;
[imageLayer setCornerRadius:10];
[imageLayer setBorderWidth:1];
imageLayer.borderColor=[[UIColor lightGrayColor] CGColor];

我不喜欢这种方式所以我创建了一个名为DetailTextView的UITextView子类。 我应该如何改变边界颜色并绕过子类内的角落?

1 个答案:

答案 0 :(得分:1)

你可以看看这个帮助我很多的要点:https://gist.github.com/pix0r/1074843

如果像我一样使用Interface Builder实例化UITextView,您可能希望在awakeFromNib中设置属性,而不是init。例如:

- (void)setProperties
{
    self.cornerRadius = 5.0f;
    self.borderWidth = 1.0f;
    self.borderColor = self.tintColor;
}