ios - UITextField 的文本插入?

标签 ios cocoa-touch uitextfield

我想插入UITextFieldtext

这可能吗?

最佳答案

重写 -textRectForBounds: 只会更改占位符文本的插入。要更改可编辑文本的插入,您还需要覆盖 -editingRectForBounds:

// placeholder position
- (CGRect)textRectForBounds:(CGRect)bounds {
     return CGRectInset(bounds, 10, 10);
}

// text position
- (CGRect)editingRectForBounds:(CGRect)bounds {
     return CGRectInset(bounds, 10, 10);
}

关于ios - UITextField 的文本插入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6535541/

相关文章:

objective-c - Cocoa Touch 上不显示 UIButton 的 titleLabel.text

iOS iPad 应用程序不隐藏键盘

ios - 在 ViewdidLoad 之外添加 UITextField

ios - 在 iOS 中完成调度组操作后延迟执行方法

iphone - NSUserDefaults 在两个不同的类中为键返回不同的值

iphone - 将街道名称和城市反向地理编码为文本

ios - 如何在导航 Controller 中推送 UIViewController 之前关闭键盘

iphone - 按钮在 3.5 英寸格式中消失 (Xcode)。

ios - 我如何在没有谷歌帐户的情况下使用 Firebase App 分发?

ios - 两次显示带导航栏的模态,无法获取第一个模态