iOS UI常用控制項

2021-07-14 18:55:33 字數 1849 閱讀 3697

● 屬性標籤 使得成為全域性變數

@property(nonatomic,strong) 型別+自定義名稱
// 標題標籤

@property(nonatomic,strong)uilabel *titlelabel;
// 左邊按鈕

@property(nonatomic,strong)uibutton *leftbtn;
// 右邊標籤

@property(nonatomic,strong)uibutton *rightbtn;
// 顯示

@property(nonatomic,strong)uiimageview *myimageview;
// 通過陣列實現對的呼叫

@property(nonatomic,strong)nsarray *imagenames;
● 標籤uilable

// 標籤位置設定 frame表明控制項的座標和寬和高

self.titlelabel =[[uilabel alloc]initwithframe:cgrectmake(origin.x,origin.y,size.width,size.heigh)];
// 標籤文字名稱

self.titlelabel.text=@"標籤名稱" ;
// 標籤居中

self.titlelabel.textalignment = nstextalignmentcenter;
// 標籤展示到測試視窗

[self.view addsubview:self.titlelabel];
● 按鈕uibutton

// uibutton buttonwithtype表示按鍵型別及狀態

uibutton *button = [uibutton buttonwithtype:uibuttontypeinfolight];
// 給按鈕設定forstate按鈕狀態

[button setbackgroundimage:image forstate:uicontrolstatenormal];
// 按鈕監聽

[button addtarget:self action:@selector(btnclicklister) forcontrolevents:uicontroleventtouchupinside];
// 新增到檢視上面

[ self.view addsubview:button];
● 設定相框uiimageview及其大小屬性

uiimageview *imageview = [[uiimageview alloc]initwithframe:cgrectmake(origin.x,origin.y,size.width,size.heigh)];

uiimage *image1 = [uiimage imagenamed:@"檔名"];

// 設定imageview顯示的 即把匯入到相簿中去

imageview.image = image1;

[self.view addsubview:imageview];

IOS UI控制項 label

ui uesr inte ce 使用者介面 ui設計是指對軟體的人機互動 操作邏輯 介面美化的完整設計。ui處於ios四層結構的最上層 cocoa touch 並且放置於uikit框架下。uilabel 1.基本屬性 void dealloc 建立乙個label方法 void createlabel...

iOS UI控制項之UIButton

恢復內容開始 狀態 uicontrolevents 的取值 typedef ns options nsuinteger,uicontrolevents 設定button內部文字和的方法 void settitle nsstring title forstate uicontrolstate stat...

iOS UI 基本控制項之UISwitch

uiswitch 開關,預設為關 ios開發中必不可少的基本控制項,主要用於只有兩種的選擇,比如飛行模式等等,本文主要是列出常用的屬性及方法 注xcode版本為7.2 預設狀態 屬性 property nullable nonatomic strong uicolor ontintcolor 開著的...