向UITextField添加右边距

时间:2014-05-10 15:37:16

标签: ios uitextfield

我的UITextField包含一个详细信息披露按钮,我用它来推广选择器视图。在iOS7中,文本与按钮重叠。我想在字段中添加右边距,以便省略号或文本不与按钮重叠。

1 个答案:

答案 0 :(得分:0)

UITextField子类并覆盖textRectForBounds:以提供一个更窄的矩形(因此,从右边填充),如下所示:

- (CGRect) textRectForBounds: (CGRect) bounds {
    CGRect r = [super textRectForBounds: bounds];
    r.size.width -= 50; // or some number to be determined by experimentation
    return r;
}
相关问题