LoginSignup
0
0

More than 5 years have passed since last update.

設定內容在 UIButton 中對齊位置

Posted at

可以設定的對齊屬性

  • contentHorizontalAlignment (型別為 UIControlContentHorizontalAlignment)
  • contentVerticalAlignment (型別為 UIControlContentVerticalAlignment)

在一個初始化後的按鈕 instance (實例,實體),這兩個 property 的預設值分別是 UIControlContentHorizontalAlignmentCenter 以及 UIControlContentVerticalAlignmentCenter

也就是 UIButton 預設所看到的垂直及水平置中的文字或圖片。

型別說明

各自對齊方式的常數:

垂直 - UIControlContentVerticalAlignment

typedef enum {
   UIControlContentVerticalAlignmentCenter  = 0,
   UIControlContentVerticalAlignmentTop     = 1,
   UIControlContentVerticalAlignmentBottom  = 2,
   UIControlContentVerticalAlignmentFill    = 3,
} UIControlContentVerticalAlignment;

依序分別是 置中(Center) 、 置頂(Top) 、 置底(Bottom) 、 佈滿(Fill)

水平 - UIControlContentHorizontalAlignment

typedef enum {
   UIControlContentHorizontalAlignmentCenter = 0,
   UIControlContentHorizontalAlignmentLeft    = 1,
   UIControlContentHorizontalAlignmentRight = 2,
   UIControlContentHorizontalAlignmentFill   = 3,
} UIControlContentHorizontalAlignment;

依序分別是 置中(Center) 、 置左(Left) 、 置右(Right) 、 佈滿(Fill)

0
0
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
0
0