问题 - [CALayer setBorderColor:]

use*_*878 4 iphone uitextview iphone-sdk-3.0

我希望在我的textview周围有边框; 为此,我做了以下事情:

textView.layer.borderWidth = 5.0f;
textView.layer.borderColor = [UIColor grayColor];   
Run Code Online (Sandbox Code Playgroud)

我收到以下警告:

warning: passing argument 1 of 'setBorderColor:' from incompatible pointer type
Run Code Online (Sandbox Code Playgroud)

Update1:​​我的边框不可见

Jon*_*ing 19

你的问题是-[CALayer setBorderColor:]需要一个类型的对象CGColorRef.您需要做的是将颜色对象转换为符合:

textView.layer.borderColor = [UIColor grayColor].CGColor;
Run Code Online (Sandbox Code Playgroud)

我希望有所帮助!