1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[Swift] コードで作成したUITextFieldに余白を作る

Posted at

はじめに

掲題の通りに、UITextFieldに余白を作る方法。

UITextFieldを継承したカスタムクラスを作成して、余白を作るとという記事が多かったがもっと簡単な物があったので備忘録的に残す。

以下を設定するだけ

textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 0))
// widthはお好みで設定してください
textField.leftViewMode = UITextField.ViewMode.always

以上!!!

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?