UILabel 詳細說明

2021-06-16 16:37:09 字數 1529 閱讀 4292

uilabel屬性及應用

uilabel *label1 =[ [uilabel alloc] initwithframe:cgrectmake(20,40,280,80)];  //建立label

label1.backgroundcolor = [ uicolor graycolor];

label1.tag = 91;  //設定tag

label1.text = @"helloworld";  //設定標籤文字

label1.font = [ uifont fontwithname:@"arial" size:30];   //文字字型和文字大小

label1.textalignment = uitextalignmentcenter;    //對齊方式

typedef enumuitextalignment;

label1.textcolor = [ uicolor bluecolor];    //設定文字顏色

label1.linebreakmode = uilinebreakmodetailfruncation;  //超出label1邊界文字的擷取方式

typedef enum

label1.adjustsfontsizetofitwidth = yes;    //文字文字自適應大小(如果文字font要偏小時)

label1.baselineadjustment = uibaselineadjustmentaligncenters;   //控制文字基線位置,一行文字有效

typedef enum{

uibaselineadjustmentalignbaselines = 0,  //預設值文字上端位於label1中線對齊

uibaselineadjustmentaligncenters,             //文字中線位於label1中線對齊

uibaselineadjustmentnone,                        //文字最低端與label1中線對齊

}uibaselineadjustment;

label1.numberofline = 2;         //文字最多行數,為0時沒有最大行數限制

label1.minimumfontsize = 10.0;  //最小字型行數為1時有效  預設0.0

label1.highlighted = yes;  //設定文字高亮

label1.enabled = yes;  //文字是否可變

label1.backgroundcolor = [ uicolor clearcolor];   //去掉背景色

label1.shadowcolor = [ uicolor graycolor];    //文字陰影顏色

label1.shadowoffset = cgrectmake(1.0,1.0);    //陰影大小

label1.userinteractionenabled = yes;     //能否與使用者互動

[self.view addsubview:label1];

[label1 release];

UILabel 詳細說明

uilabel屬性及應用 uilabel label1 uilabel alloc initwithframe cgrectmake 20,40,280,80 建立label label1.backgroundcolor uicolor graycolor label1.tag 91 設定tag l...

Struts config xml 詳細說明

頁面中表單對應的bean儲存表單資料,驗證 type hello.helloform formbean 對應的包名.類名 路徑的邏輯名,此項必須有 path action1.do 指向 或重定向的uri.此項是必需的,必須以 開頭.請求訪問action的路徑,必須以 開頭 type hello.he...

Struts config xml 詳細說明

頁面中表單對應的bean儲存表單資料,驗證 type hello.helloform formbean 對應的包名.類名 name forward1 路徑的邏輯名,此項必須有 path action1.do 指向 或重定向的uri.此項是必需的,必須以 開頭.name forward2 path a...