iOS --- UI系类之UITextField

来源:互联网 发布:淘宝这么把排名搞前 编辑:程序博客网 时间:2024/06/07 04:11

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];}

发现高度也该变了。

参考博客https://my.oschina.net/agony/blog/387322

0 0