我正在使用文本视图作为评论编辑器。
在属性检查器中,我找不到类似边框样式属性的任何内容,以便我可以使用圆角矩形,例如UITextField
.
所以,问题是:我该如何设计UITextView
like a 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 及更高版本,但我想现在无论如何它都是事实上的平台。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)