UITextField的文本插入?
我想插入一个 UITextField 的 文本 。 这可能吗? #1楼 使用 textRectForBounds: 是正确的方法。 我将其包装在子类中,因此您可以简单地使用 textEdgeInsets 。 参见 SSTextField 。 #2楼 我能够通过以下方式做到这一点: myTextField.layer.sublayerTransform = CATransform3DMakeTranslation(5, 0, 0); 当然,请记住导入QuartzCore并将框架添加到您的项目中。 #3楼 如果只需要左边距,则可以尝试以下操作: UItextField *textField = [[UITextField alloc] initWithFrame:...]; UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, textField.frame.size.height)]; leftView.backgroundColor = textField.backgroundColor; textField.leftView = leftView; textField.leftViewMode = UITextFieldViewModeAlways; 这个对我有用。 希望对您有所帮助。 #4楼