UITextView 缩进问题:
例如,我希望“测试”文本稍微正确,我应该设置什么属性?
试试这个
UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
self.yourtextField.leftView = paddingView;
self.yourtextField.leftViewMode = UITextFieldViewModeAlways;
创建一个子类并覆盖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);
}
试试这个简单的方法....
textfield.frame = CGRectMake(textfield.frame.origin.x+10, textfield.frame.origin.y, textfield.frame.size.width, textfield.frame.size.height);