栃木県のJavaエンジニア、WEBプログラマーのためのサイト

2015.03.11[iOS] UILabel, UIButton で角丸

UIButton

ボタンの角を丸くしたい場合

button.layer.cornerRadius = 3

に、半径を設定

Storyboard や XIB 上で指定する場合は、User Defined Attributes で設定

"UIButton Corner Radius"

UILabel

ラベルの角を丸くしたい場合は、layer.cornerRadius に加え、clipsToBounds も有効にします

label.layer.cornerRadius = 3
label.clipsToBounds = true

"UILabel Corner Radius"

確認

ストーリーボード(プレビュー含む)上は角丸表示されませんのでシミュレータで確認しましょう

"iOS Simulator"

この記事について
  • スッキリ (3)
  • 普通 (0)
  • 消化不良 (2)