ios - 如何在我的文本字段中添加顶部填充(Objective-c)

标签 ios objective-c textfield padding

我有文本字段、自定义类。

但我不知道如何使用 Insets。我知道函数但不知道如何使用它们。

Notes textField

最佳答案

在您的自定义类中使用此方法

- (CGRect)textRectForBounds:(CGRect)bounds {
        return CGRectMake(bounds.origin.x + yourPading, bounds.origin.y + yourPading,
                          bounds.size.width - yourPading, bounds.size.height - yourPading);
    }
    - (CGRect)editingRectForBounds:(CGRect)bounds {
        return [self textRectForBounds:bounds];
    }

关于ios - 如何在我的文本字段中添加顶部填充(Objective-c),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58642980/

相关文章:

ios - (Sphero) 机器人 sdk 不适用于 64 位架构和 ios 中的 ios 8.2

iphone - 如何在 tabbarcontroller 的特定 View 中添加右栏按钮项

ios - Swift 3 更改单元格形状和属性

objective-c - 在 UIImageView 中居中 UIActivityIndi​​catorView

iOS 11 测试版 : Mail View Controller called from app will not send mail

flutter - 如何将按钮放置在屏幕的底部中央?

iphone - 我可以确定/如何确定设备是否有振动吗?

iOS Swift 使用 for 循环在 TableView Cell 中添加两个 View

dart - Flutter:叠加触发重建中的文本字段

android - Jetpack 将数字输入输入到 TextField