UITextField のテキストインセット? 質問する

UITextField のテキストインセット? 質問する

テキストを挿入したいと思いますUITextField

これは可能ですか?

ベストアンサー1

上書きするとプレース-textRectForBounds:ホルダーテキストのインセットのみが変更されます。編集可能なテキストのインセットを変更するには、上書きも行う必要があります。-editingRectForBounds:

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

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

おすすめ記事