iOS UIButton各類屬性設定大全

2021-12-29 22:40:29 字數 1405 閱讀 6057

//設定自定義的按鈕

//uibutton *button1=[uibutton buttonwithtype:uibuttontypecustom];

//設定乙個圓角的按鈕

uibutton *button1=[uibutton buttonwithtype:uibuttontyperoundedrect];

button1.frame=cgrectmake(80,250,250, 30);//按鈕的位置座標

[button1 settitle:@"button1" forstate:uicontrolstatenormal];//普通狀態按鈕標題

[button1 settitle:@"高亮狀態" forstate:uicontrolstatehighlighted];//高亮狀態的按鈕標題

//高亮狀態光暈效果

[button1 setshowstouchwhenhighlighted:yes];

//設定標題的顏色

[button1 settitlecolor:[uicolor redcolor] forstate:uicontrolstatenormal];

//設定標題的字型大小

[button1.titlelabel setfont:[uifont boldsystemfontofsize:20]];

//設定背景顏色

[button1 setbackgroundcolor:[uicolor bluecolor]];

//被拉伸式地設定背景

//保持原來大小地設定背景

//監聽事件

[button1 addtarget:self action:@selector(click_button) forcontrolevents:uicontroleventtouchupinside];

}-(void)click_button

未完,待續更新.........

line height各類屬性值

line height支援屬性值 1.normal 預設屬性 跟著使用者的瀏覽器走,且與元素字型關聯 normal值 字型大小 100 2.使用數值作為行高值。如 line height 1.5 根據當前元素的font size大小計算 line height 1.5 20px font size ...

python 類屬性 用處 Python類屬性詳解

類屬性1.類定義後就存在,而且不需要例項化 2.類屬性使得相同類的不同例項共同持有相同變數 類屬性例項 attrb.py class testcss cssa class attribe def init self self.a 0 self.b 10 def info self print a s...

類屬性 例項屬性

例項屬性 物件屬性 顧名思義,類屬性就是類物件所擁有的屬性,它被所有類物件的例項物件所共有,在記憶體中只存在乙個副本,這個和c 中類的靜態成員變數有點類似。對於公有的類屬性,在類外可以通過類物件和例項物件訪問 例項如下 class people object name tom 公有的類屬性 age ...