iOS學習筆記1 UIView

2021-06-13 02:53:46 字數 1163 閱讀 9500

接觸了一段時間ios開發,現在開始試著放開inte***ce builder工具,利用code完成介面的製作。

第一天,我們來理解uiview的概念。uiview是uikit框架下,uiresponder的子類,他可以說是程式畫面下最小的元素。無論是uilabel,還是uibutton,都是uiview的子類。我們可以這樣理解,應用程式畫面幾乎都是各種uiview堆砌而成的。

今天我們通過呼叫uilabel,來嘗試完成uiview的位置、尺寸和顏色等屬性的呼叫

的方法中進行操作

此處就**做下解釋吧,大神們請繞道了,嘿嘿:

//首先對uiwindow進行初始化,因為樓主建立工程時,預設選擇了arc,所以此處沒有了autorelease

self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];

//設定uiwindow的背景色為藍色

self.window.backgroundcolor = [uicolor bluecolor];

//初始化乙個uilabel標籤

uilabel *label = [[uilabel alloc]initwithframe:cgrectzero];

//設定label的尺寸

label.frame = cgrectmake(0, 0, 200, 50);

//設定label的中心點座標位置

label.center = cgpointmake(160, 240);

//設定label的顯示內容、顏色、居中、背景色

label.text =@"uiview";

label.textcolor = [uicolor redcolor];

label.textalignment = uitextalignmentcenter;

label.backgroundcolor = [uicolor clearcolor];

//在window檢視上加上label檢視,達到顯示效果

[self.window addsubview:label];

[self.window makekeyandvisible]

iOS動畫1 UIView動畫

ios動畫基礎是core animation核心動畫。core animation是ios平台上負責圖形渲染與動畫的基礎設施。由於核心動畫的實現比較複雜,蘋果提供了實現簡單動畫的介面 uiview動畫。uiview動畫封裝在uiview的category中,主要實現一些簡單和常用的動畫。uiview...

iOS開發學習之UI篇 1 UIView

int main int argc,char argv 建立應用程式主視窗,一般乙個應用程式只有乙個視窗,uiwindow frame 檢視的大小 uiscreen mainscreen bounds 整個螢幕的大小 初始化的時候,將window的大小設定為整個螢幕。self window uiwi...

動畫1 UIView動畫

uiview動畫簡單易用,可以滿足普通的動畫需求 寫法1 uiview beginanimations animationid context null 動畫效果 uiview commitanimations 寫法2 uiview animatewithduration 1.0 animation...