我正在使用文本视图作为评论撰写者。
在属性检查器中,我找不到边框样式属性之类的东西,因此可以使用圆角矩形,例如UITextField
。
所以,问题是:如何风格UITextView
像一个UITextField
带有圆角的矩形?
没有必须选择的隐式样式,它涉及使用QuartzCore
框架编写一些代码:
//first, you
#import <QuartzCore/QuartzCore.h>
//.....
//Here I add a UITextView in code, it will work if it's added in IB too
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(50, 220, 200, 100)];
//To make the border look very close to a UITextField
[textView.layer setBorderColor:[[[UIColor grayColor] colorWithAlphaComponent:0.5] CGColor]];
[textView.layer setBorderWidth:2.0];
//The rounded corner part, where you specify your view's corner radius:
textView.layer.cornerRadius = 5;
textView.clipsToBounds = YES;
它仅适用于OS 3.0及更高版本,但我想现在它仍然是事实上的平台。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句