UITextField具体用法和属性
请参见这篇博客http://blog.csdn.net/tskyfree/article/details/8121915/写的很详细。
如何更改UITextField的高度
通过自定义子类实现修改UITextField高度
拖控件,我们能看出来textfield是高度30固定的
纯代码写了一下在子类中覆盖- (CGRect)borderRectForBounds:(CGRect)bounds
方法
/**
* 通过以下代码实现设置文本框高度
* 100是所希望的高度
*/
- (CGRect)borderRectForBounds:(CGRect)bounds
{
bounds.size.height = 100;
return bounds;
}
但是在一个类里面初始化的时候传入frame发现也可以改变。
- (void)initUI
- (void)initUI{
_a = [[UITextField alloc]initWithFrame:CGRectMake(30, 30, 100, 100)];
_a.backgroundColor = [UIColor redColor];
[self.view addSubview:_a];
}
发现高度也该变了。