Sha*_*rma 5 objective-c uitextfield ios
我已将斜体字体添加到UITextFieldwith UITextAlignmentLeft。当用户键入例如“j”的字符时,该字符在左侧被切断。我尝试过添加填充、自定义textrectBounds&editingtextRectBounds但它们都不起作用。
您可以创建 UILabel 的超级简单子类:
class PaddingLabel: UILabel {
override func drawText(in rect: CGRect) {
let insets = UIEdgeInsets(top: 0, left: 2, bottom: 0, right: 2)
super.drawText(in: rect.inset(by: insets))
}
}
Run Code Online (Sandbox Code Playgroud)
然后,将您的 UILabel 类设置为PaddingLabel并根据您的需要调整插入值。
| 归档时间: |
|
| 查看次数: |
553 次 |
| 最近记录: |