美文网首页
让 UITextField的光标往右移

让 UITextField的光标往右移

作者: Coder大雄 | 来源:发表于2016-08-30 22:41 被阅读85次

UITextField有个属性叫 leftView,我们首先要设置 leftView的fram

[[UIView alloc] initWithFrame:CGRectMake(50, 0, 50, 0)];

然后还要设置一个枚举的属性 leftViewMode

或者自己写一个类来继承UITextField。重写下面的方法

/*!
 *  @method
 *  @abstract TextField里面的方法
 *  @discussion
 */
- (CGRect)textRectForBounds:(CGRect)bounds {
    bounds.origin.x += 10;
    return bounds;
}

- (CGRect)editingRectForBounds:(CGRect)bounds {
    bounds.origin.x += 10;
    return bounds;
}

相关文章

网友评论

      本文标题:让 UITextField的光标往右移

      本文链接:https://www.haomeiwen.com/subject/dqrqettx.html