1.UI層次圖
官網(wǎng)文檔中有,視頻中Sundy也說要學(xué)會利用官網(wǎng)來學(xué)習(xí)UIKit闺兢,同時也演示了如何利用官網(wǎng)來查找自己需要的資料犀暑。官網(wǎng)的資料的確詳細,但是英文不好的話可能會有些困難拢肆。不過還好减响,這種技術(shù)性很強的文獻,英文好的人也不一定能看懂郭怪,需要懂技術(shù)知識才能看懂支示。嘗試看一下,說不定能看懂呢~
UIKit User Interface Catalog這個文檔比較有幫助
2.學(xué)習(xí)組件四件套:
1)放在哪兒鄙才?層級颂鸿、位置、邊界咒循?
2)組件是什么外觀(大小据途,顏色,透明叙甸,布局適配……)
3)會不會動颖医?有沒有什么動畫效果?
4)有什么行為裆蒸?哪些事件熔萧?
3.UILabel
中的view中屬性可以總結(jié)一下,比較有用
4.UIControl
的事件僚祷,好幾個事件總結(jié)一下比較好
5.UIButton
介紹了在storyboard中屬性面板中的各個屬性
學(xué)好storyboard中的屬性面板
6.UISegmented
selectedSegmentIndex選中的segment控件的值
往往用到的事件為:ValueChanged
numberOfSegments在storyboard中可以看到的佛致,鼠標(biāo)放上就會出現(xiàn)
insertSegmentWithTitle增加一個這個能在故事板中看到嗎?不一定的啊
removeSegmentAtIndex減少一個
7.UITextField
storyboard中的各個屬性介紹
resignFirstResponder()失去焦點辙谜,鍵盤消失
事件Did End On Exit與resignFirstResponder()組合使用俺榆,讓鍵盤可以消失
8.UISlider
storyboard中的各個屬性介紹
經(jīng)常用到的事件為:ValueChanged
setThumbImage更換滑塊圖片
9.UISwitch
storyboard中的各個屬性介紹
經(jīng)常用到的事件為:ValueChanged
sender.on
10.UIActivityIndicatorView
storyboard中的各個屬性介紹
像素固定,大小固定装哆,不能變化罐脊。
starAnimating()
stopAnimating()
11.UIProgressView
storyboard中的各個屬性介紹和UIView的屬性有相似性定嗓,繼承了UIView
NSTimer.scheduledTimerWithTimelnterval記步函數(shù)
12.UIStepper
storyboard中的各個屬性介紹
經(jīng)常用到的事件為:ValueChanged
NSString( format:轉(zhuǎn)換符)值的轉(zhuǎn)換
%s字符串
13.UIImage
storyboard中的各個屬性介紹
animationImages圖片的數(shù)組.animationImages = [UIImage(named: )]
animationRepeatCount重復(fù)次數(shù)
animationDuration循環(huán)的間隔時間
startAnimating()開始動畫
stopAnimating()結(jié)束動畫
14.UIAlertView
不是在控件庫中,是需要靠代碼實現(xiàn)萍桌。
有三個步驟:
1)創(chuàng)建UIAlertView
UIAlertView(Title:? “”? , message: “”, delegate:self ,cancelButtonTitle:,otherButtonTitle:).show()
2)設(shè)置按鈕的事件監(jiān)聽
clickedButtonAtIndex
fun alertView(alertView: UIAlertView, clickedButtonAtIndex buttonIndex: Int ) {
}
3)顯示UIAlertView
.show()
會用到的其他的功能命令:
alertViewStyle 變化AlertView的style宵溅,不同的樣式。
textFieldAtIndex索引的值
15.UIActionSheet
不是在控件庫中上炎,是需要靠代碼實現(xiàn)恃逻。
有三個步驟:
1)創(chuàng)建UIActionSheet
UIActionSheet(title:,delegate:,cancelButtonTitle:,destructiveButtonTitle:) destructiveButtonTitle是確認按鈕
2)設(shè)置按鈕的事件監(jiān)聽
clickedButtonAtIndex
fun actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int ) {
}
3)顯示UIActionSheet
.showFromBarButtonItem(…)
.showFromRect(…)顯示在某個區(qū)域
.showFromTabBar(…)
.showFromToolBar(…)
.showInView(…)顯示在某個視圖中
常用到的其他的功能:
actionSheetStyle
16.UIDatePicker
toryboard中的各個屬性介紹
經(jīng)常用到的事件為:ValueChanged
NSDateFormatter格式器
var format = NSDateFormatter( )
format.dateStyle = NSDateFormatterStyle.ShortStyle//設(shè)置日期格式
format.dateFormat = “yyyy年MM月dd日,HH小時mm分ss秒” //dateFormat是可以自定義日期的顯示的樣式藕施,上面的style是xcode給定的一種樣式寇损,
format.stringFromDate(sender.date)? //把datepicker的date日期轉(zhuǎn)為String
換成倒計時的形式后
.coutDownDuration這個命令
17.UIPickerView
delegate:UIPickerViewDelegate
都是可選的函數(shù)
行的寬度和高度;
data?source:UIPickerViewDataSource
兩個必選的函數(shù)
1)numberOfComponentsInPickerView //顯示列數(shù)
2)numberOfRowsInComponent //顯示行的數(shù)量
.delegate = self
.dataSource = self
a.定義數(shù)據(jù)
b.制定列數(shù)(Component )
c.實現(xiàn)顯示 titleForRow
顯示多行用if語句裳食,component == 0
選擇事件函數(shù):didSelectRow
reloadComponet(1)
selectRow()讓第二列出現(xiàn)時润绵,焦點一直處于第一行
18.UIWebView
storyboard中的各個屬性介紹
加載網(wǎng)頁的方法:loadData?; ?loadHTMLString?; ?loadRequest ; ?loading
停止:stopLoading
下一步:goForward()
上一步:goBack()
刷新:reLoad()
UIWebViewDelegate委托下都是可選的函數(shù)
監(jiān)聽瀏覽器的方法
webViewDidStartLoad
webViewDidFinishLoad
19.UIToolbar
繼承UIView
storyboard中的各個屬性介紹
toolbar1.items?.append(buttonItem1)
20.UIScrollView
繼承UIView
storyboard中的各個屬性介紹
contentSize
contentInset
contentOffset偏移量
indicatorStyle
UIScrollViewDelegate的方法都是可選的
Paging Enabled可以用在引導(dǎo)頁上
引導(dǎo)頁可能用到的功能或者命令:
Paging Enabled
建立4個UIView
addSubview
21.UIPageControl
繼承UIView
storyboard中的各個屬性介紹
UIPageControl中的currentPage和UIScrollView中的contentOffset.x?組合使用可以計算處于第幾頁
UIScrollView中的scrollRectToVisible起到顯示的作用