#二、可能用到的UI UI控件名稱 | 中文名稱 | | UI控件名稱 | 中文名稱 -- | -- | -- | -- | -- <font color=red >UIButton</font> | <font color=red >按鈕</font> | | <font color=red >UIScrollView</font> | <font color=red >滾動的控件</font> <font color=red >UILabel</font> | <font color=red >文本標籤</font>| | <font color=blue >UIPageControl</font>| <font color=blue >分頁控件</font> <font color=red >UITextField</font> | <font color=red >文本輸入框</font>| | <font color=red >UIImageView</font>| <font color=red >圖片顯示</font> UIProgressView | 進度條| | UISlider| 滑塊 <font color=blue >UISwitch | <font color=blue >開關| | UISegmentControl| 選項卡 <font color=blue >UIActivityIndicator | <font color=blue >圈圈</font>| | <font color=red >UIAlertView</font> | <font color=red >對話框(中間彈框)</font> <font color=blue >UIActionSheet</font> | <font color=blue >底部彈框</font>| | <font color=blue >UITextView</font> | <font color=blue >能滾動的文字顯示控件</font> <font color=red >UITableView</font> | <font color=red >表格</font>| | <font color=blue >UICollectionView</font> | <font color=blue >九宮格</font> <font color=blue >UIPickerView</font> | <font color=blue >選擇器</font>| | <font color=blue >UIDatePicker</font>| <font color=blue >日期選擇器</font>
<font color=blue >UIWebView</font> | <font color=blue >網頁顯示控件</font> | | UIToolbar | 工具條 <font color=red >UINavigationBar</font> | <font color=red >導航條</font>| | … | …ios
<font color=red >* 紅色</font> 代表最經常使用,<font color=blue >藍色</font> 表明通常,黑色表明幾乎不用(這不是絕對的,僅供參考)app
#三、UIView ##Inherits From ##屬性 ###1. alpha(視圖的透明度)ide
// 徹底透明 view.alpha = 0; // 不透明 view.alpha = 1;
###2. clipsToBounds函數
// 默認是NO,當設置爲yes時,超出當前視圖的尺寸的內容和子視圖不會顯示。 view.clipsToBounds = YES;
###3.hidden(是否可見)工具
// 默認是NO,當設置爲yes,視圖就看不見了。 view.hidden = YES;
###4.userInteractionEnabled(是否可響應事件)ui
// 默認爲YES,若是設置爲No,view就不能和用戶交互了。(即不能響應事件) view.userInteractionEnabled = NO;
###5. tag(標記)code
// 默認爲0,用來標記視圖的 view.tag = 0;
###6. exclusiveTouch 默認爲No exclusiveTouch的意義在於:若是當前設置了exclusiveTouch的UIView是整個觸摸事件的第一響應者,那麼到你全部的手指離開屏幕前其餘的UIView是沒法接受到整個事件週期內全部的觸摸事件。orm
###7. CGRect framehtm
###8. CGPoint center
###9. CGRect bounds
###10. CGAffineTransform transform
// 建立一個x、y方向的縮放比例分別爲sx、sy的形變值 CGAffineTransformMakeScale(CGFloat sx, CGFloat sy) // 建立一個旋轉角度爲angle的形變值 CGAffineTransformMakeRotation(CGFloat angle) // 在形變值t的基礎上,再進行縮放,x、y方向的縮放比例分別爲sx、sy,而後返回一個新的形變值 CGAffineTransformScale(CGAffineTransform t, CGFloat sx, CGFloat sy) // 在形變值t的基礎上,再進行旋轉,旋轉角度爲angle,而後返回一個新的形變值 CGAffineTransformRotate(CGAffineTransform t, CGFloat angle)
###11. superview(父視圖) 返回當前視圖的父視圖。(只讀) ###12. window(當前視圖) 返回當前視圖的窗口。(窗口)
獲取根視圖的superview和window時,須要注意,在viewdidload中是獲取不到的,viewdidload只是視圖加載完成,並無添加到窗口中,所以須要在viewDidAppear方法中才能獲取到。那時候視圖才被添加到窗口中。
- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"%@",self.view.superview); // 沒有值 NSLog(@"%@", self.view.window); // 沒有值 } - (void)viewDidAppear:(BOOL)animated { NSLog(@"%@",self.view.superview); // 有值 NSLog(@"%@", self.view.window); // 有值 }
###13.autoresizesSubviews 默認爲YES,表示當父視圖尺寸改變時,子視圖也會隨着改變。 ###14.autoresizingMask 默認爲UIViewAutoresizingNone,不會自動伸縮。 ###15.contentMode 設置內容模式。
###16.backgroundColor(背景顏色) 默認是nil。
// 設置背景顏色爲紅色 self.view.backgroundColor = [UIColor redColor];
###17.UIView經常使用添加子視圖方法
//加一個視圖到一個視圖裏面 addSubview: //將一個視圖移到前面 bringSubviewToFront: //將一個視圖推送到背後 sendSubviewToBack: //把視圖移除 removeFromSuperview //插入視圖 並指定索引 insertSubview:atIndex: //插入視圖在某個視圖之上 insertSubview:aboveSubview: //插入視圖在某個視圖之下 insertSubview:belowSubview: //交換兩個位置索引的視圖 exchangeSubviewAtIndex:withSubviewAtIndex:
#四、界面 ##1.界面文件 ###1.1 storyboard文件 描述軟件界面,重量級,通常用來描述整個軟件的全部界面。
###1.2 Xib文件 描述軟件界面,輕量級,通常用來描述局部界面
##2. 兩種文件比較 ###2.1 共同點
###2.2 不一樣點