use*_*681 4 colors uitextfield uitextview ios7
我希望UITextField有多行,在这个问题上快速谷歌之后我发现我应该使用TextView所以当我想要多行时,我确实切换了我的代码以使用UITextView.我的视图仍然有其他一行textField我想保留.
为了使我的TextView看起来像TextField,我不得不添加代码来设置边框和半径,但它们在iOS7上看起来有点不同.有人知道吗:
如果有继续使用文本字段的多行文字,我都是耳朵,我切换使用它.
最好的祝福,

我用这个:
textView.layer.borderColor = [[UIColor colorWithRed:215.0 / 255.0 green:215.0 / 255.0 blue:215.0 / 255.0 alpha:1] CGColor];
textView.layer.borderWidth = 0.6f;
textView.layer.cornerRadius = 6.0f;
Run Code Online (Sandbox Code Playgroud)
params的微小差异使它看起来更像UITextField(我希望).
我有一个 UITextView 的小子类,它在 iOS 7 中与 UITextField 具有相同的外观
界面为空:
@interface MyTextView : UITextView
@end
Run Code Online (Sandbox Code Playgroud)
该实现覆盖了“可编辑”属性的初始化和设置器:
@implementation MyTextView
//================================================================================
- (id) initWithFrame: (CGRect) frame
{
self = [super initWithFrame:frame];
if (self)
{
[self commonInit];
}
return self;
}
//================================================================================
- (id) initWithCoder: (NSCoder *) aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
[self commonInit];
}
return self;
}
//================================================================================
- (void) commonInit
{
self.layer.borderWidth = 1.0f;
self.layer.borderColor = [[UIColor colorWithRed:232.0/255.0
green:232.0/255.0 blue:232.0/255.0 alpha:1] CGColor];
self.layer.cornerRadius = 6;
}
//================================================================================
- (void) setEditable: (BOOL) editable
{
[super setEditable:editable];
if (editable)
{
self.backgroundColor = [UIColor whiteColor];
}
else
{
self.backgroundColor = [UIColor colorWithRed:250.0/255.0
green:250.0/255.0 blue:250.0/255.0 alpha:1];
}
}
//================================================================================
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1680 次 |
| 最近记录: |