5

例如,我想要

UITextView 缩进问题:

例如,我希望“测试”文本稍微正确,我应该设置什么属性?

4

3 回答 3

12

试试这个

    UIView *paddingView           = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
    self.yourtextField.leftView             = paddingView;
    self.yourtextField.leftViewMode         = UITextFieldViewModeAlways;
于 2012-05-23T18:05:58.330 回答
8

创建一个子类并覆盖textRectForBounds:and editingRectForBounds:。您的新实现可能看起来像

- (CGRect)textRectForBounds:(CGRect)bounds;
{
    return CGRectInset([super textRectForBounds:bounds], 10.f, 0.f);
}

- (CGRect)editingRectForBounds:(CGRect)bounds;
{
    return CGRectInset([super editingRectForBounds:bounds], 10.f, 0.f);
}
于 2012-05-23T15:17:29.023 回答
1

试试这个简单的方法....

textfield.frame = CGRectMake(textfield.frame.origin.x+10, textfield.frame.origin.y, textfield.frame.size.width, textfield.frame.size.height);
于 2014-02-12T14:07:52.817 回答