IOS開(kāi)發(fā)(三)高級(jí)控件

IOS基礎(chǔ)控件思維導(dǎo)圖

image-20200729192506800.png

三琐旁、高級(jí)控件

1阿趁、UITabBarController

(1)常用屬性

open var selectedIndex: Int

(2)常用方法

open func setViewControllers(_ viewControllers: [UIViewController]?, animated: Bool)

(3)內(nèi)嵌控制器說(shuō)明

//子視圖正常情況下的圖片
self.tabBarItem.image

//子視圖文字
self.tabBarItem.title

//子視圖在被選狀態(tài)下的圖片
self.tabBarItem.selectedImage

//子視圖背景文字顏色
self.tabBarItem.backgroudColor

//子視圖背景文字
self.tabBarItem.backgroudValue

2僵芹、UIPageViewController-->UIPageViewControllerDelegate,UIPageViewControllerDataSource

(1)常用屬性

weak open var delegate: UIPageViewControllerDelegate?

weak open var dataSource: UIPageViewControllerDataSource? 

(2)常用方法

//構(gòu)造方法 邀跃,第一個(gè)參數(shù)決定頁(yè)面翻轉(zhuǎn)的風(fēng)格,第二個(gè)決定頁(yè)面的方向(水平Or垂直)
public init(transitionStyle style: UIPageViewController.TransitionStyle, navigationOrientation: UIPageViewController.NavigationOrientation, options: [UIPageViewController.OptionsKey : Any]? = nil)
//添加其他的控制器到pageviewcontroller中
open func setViewControllers(_ viewControllers: [UIViewController]?, direction: UIPageViewController.NavigationDirection, animated: Bool, completion: ((Bool) -> Void)? = nil)

(3)代理方法

//改變發(fā)生前
optional func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController])

//改變發(fā)生完成時(shí)
optional func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool)

//旋轉(zhuǎn)方向發(fā)生改變
optional func pageViewController(_ pageViewController: UIPageViewController, spineLocationFor orientation: UIInterfaceOrientation) -> UIPageViewController.SpineLocation

(4)數(shù)據(jù)源方法

//當(dāng)前controller的前一個(gè)controller是什么
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?
//當(dāng)前controller的后一個(gè)controller是什么
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?

3蛙紫、UINavigationController

(1)常用屬性

open var isNavigationBarHidden: Bool

open var navigationBar: UINavigationBar { get } 

(2)常用方法

 open func pushViewController(_ viewController: UIViewController, animated: Bool) 
    
open func popViewController(animated: Bool) -> UIViewController?

open func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? 

open func popToRootViewController(animated: Bool) -> [UIViewController]?

open var topViewController: UIViewController? { get } 

4拍屑、UIAlertController+UIAlertAction

(1)UIAlertAction常用屬性+方法(相當(dāng)于按鈕)

var isEnabled: Bool

//參數(shù) : 1、動(dòng)作的名字 2坑傅、動(dòng)作的類型 3僵驰、動(dòng)作執(zhí)行的閉包
public convenience init(title: String?, style: UIAlertAction.Style, handler: ((UIAlertAction) -> Void)? = nil)

(2)常用屬性

open var title: String?

open var message: String?

(3)常用方法

//三個(gè)參數(shù):1、標(biāo)題 2唁毒、標(biāo)題下的提示信息 3蒜茴、類型
public convenience init(title: String?, message: String?, preferredStyle: UIAlertController.Style)

open func addAction(_ action: UIAlertAction)

open func addTextField(configurationHandler: ((UITextField) -> Void)? = nil)

5、UITableView-->UITableViewDelegate,UITableViewDataSource

(1)常用屬性

weak open var dataSource: UITableViewDataSource?

weak open var delegate: UITableViewDelegate?

open var backgroundView: UIView?

open var separatorStyle: UITableViewCell.SeparatorStyle

open var separatorColor: UIColor?  

(2)常用方法

open func reloadData()

———————————————————————————————————————————————————————————————————————————————

open func rectForHeader(inSection section: Int) -> CGRect

open func rectForFooter(inSection section: Int) -> CGRect

open func rectForRow(at indexPath: IndexPath) -> CGRect

———————————————————————————————————————————————————————————————————————————————

open func insertRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation)

open func deleteRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation)

open func reloadRows(at indexPaths: [IndexPath], with animation: UITableView.RowAnimation)

———————————————————————————————————————————————————————————————————————————————
open func insertSections(_ sections: IndexSet, with animation: UITableView.RowAnimation)

open func deleteSections(_ sections: IndexSet, with animation: UITableView.RowAnimation)

open func reloadSections(_ sections: IndexSet, with animation: UITableView.RowAnimation)

———————————————————————————————————————————————————————————————————————————————
//注冊(cè)的作用是先自定義好一個(gè)cell的類枉证,用這個(gè)類作為復(fù)用cell的模板
open func register(_ nib: UINib?, forCellReuseIdentifier identifier: String)

open func register(_ cellClass: AnyClass?, forCellReuseIdentifier identifier: String)

open func register(_ nib: UINib?, forHeaderFooterViewReuseIdentifier identifier: String)

open func register(_ aClass: AnyClass?, forHeaderFooterViewReuseIdentifier identifier: String)

(3)代理方法

optional func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath)

optional func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int)

optional func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int)

optional func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath)

optional func tableView(_ tableView: UITableView, didEndDisplayingHeaderView view: UIView, forSection section: Int)

optional func tableView(_ tableView: UITableView, didEndDisplayingFooterView view: UIView, forSection section: Int)

———————————————————————————————————————————————————————————————————————————————

//行高
optional func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
//頭高
optional func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat
//尾高
optional func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat

func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?

optional func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView?

———————————————————————————————————————————————————————————————————————————————

optional func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath?

optional func tableView(_ tableView: UITableView, willDeselectRowAt indexPath: IndexPath) -> IndexPath?

optional func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

optional func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)

(4)數(shù)據(jù)源方法

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

optional func numberOfSections(in tableView: UITableView) -> Int

optional func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? 

optional func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String?

6矮男、UICollectionView-->UICollectionViewDelegate,UICollectionViewDataSource

(1)常用屬性

weak open var delegate: UICollectionViewDelegate?

weak open var dataSource: UICollectionViewDataSource?

(2)常用方法

 open func reloadData() 

open func insertSections(_ sections: IndexSet)

open func deleteSections(_ sections: IndexSet)

open func reloadSections(_ sections: IndexSet)
 
open func insertItems(at indexPaths: [IndexPath])

open func deleteItems(at indexPaths: [IndexPath])

open func reloadItems(at indexPaths: [IndexPath])

(3)代理方法

ptional func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool

optional func collectionView(_ collectionView: UICollectionView, shouldDeselectItemAt indexPath: IndexPath) -> Bool

optional func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)

optional func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath)

optional func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath)

optional func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath)

(4)數(shù)據(jù)源方法

optional func numberOfSections(in collectionView: UICollectionView) -> Int

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell

7、UIScrollView-->UIScrollViewDelegate

(1)常用屬性

weak open var delegate: UIScrollViewDelegate? 

//垂直方向滾動(dòng)室谚,默認(rèn)yes
open var showsVerticalScrollIndicator: Bool 

//水平方向滾動(dòng)毡鉴,默認(rèn)yes
open var showsHorizontalScrollIndicator: Bool

open var indicatorStyle: UIScrollView.IndicatorStyle

//縮放
open var minimumZoomScale: CGFloat 

open var maximumZoomScale: CGFloat 

open var zoomScale: CGFloat

//scrollview所能滑動(dòng)的范圍,可以超過(guò)屏幕尺寸
open var contentSize: CGSize 

(2)代理方法

optional func scrollViewDidScroll(_ scrollView: UIScrollView) // any offset changes

optional func scrollViewDidZoom(_ scrollView: UIScrollView) // any zoom scale changes

optional func scrollViewWillBeginDragging(_ scrollView: UIScrollView)

optional func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)

optional func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)

optional func scrollViewDidScrollToTop(_ scrollView: UIScrollView) // called when scrolling animation finished. may be called immediately if already at top

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末秒赤,一起剝皮案震驚了整個(gè)濱河市猪瞬,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌入篮,老刑警劉巖陈瘦,帶你破解...
    沈念sama閱讀 222,464評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異潮售,居然都是意外死亡痊项,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,033評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門(mén)酥诽,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)鞍泉,“玉大人,你說(shuō)我怎么就攤上這事肮帐】裕” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 169,078評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵训枢,是天一觀的道長(zhǎng)托修。 經(jīng)常有香客問(wèn)我,道長(zhǎng)恒界,這世上最難降的妖魔是什么睦刃? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 59,979評(píng)論 1 299
  • 正文 為了忘掉前任,我火速辦了婚禮十酣,結(jié)果婚禮上涩拙,老公的妹妹穿的比我還像新娘枣宫。我一直安慰自己,他們只是感情好吃环,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,001評(píng)論 6 398
  • 文/花漫 我一把揭開(kāi)白布也颤。 她就那樣靜靜地躺著,像睡著了一般郁轻。 火紅的嫁衣襯著肌膚如雪翅娶。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 52,584評(píng)論 1 312
  • 那天好唯,我揣著相機(jī)與錄音竭沫,去河邊找鬼。 笑死骑篙,一個(gè)胖子當(dāng)著我的面吹牛蜕提,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播靶端,決...
    沈念sama閱讀 41,085評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼谎势,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了杨名?” 一聲冷哼從身側(cè)響起脏榆,我...
    開(kāi)封第一講書(shū)人閱讀 40,023評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎台谍,沒(méi)想到半個(gè)月后须喂,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,555評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡趁蕊,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,626評(píng)論 3 342
  • 正文 我和宋清朗相戀三年坞生,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片掷伙。...
    茶點(diǎn)故事閱讀 40,769評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡是己,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出炎咖,到底是詐尸還是另有隱情赃泡,我是刑警寧澤寒波,帶...
    沈念sama閱讀 36,439評(píng)論 5 351
  • 正文 年R本政府宣布乘盼,位于F島的核電站,受9級(jí)特大地震影響俄烁,放射性物質(zhì)發(fā)生泄漏绸栅。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,115評(píng)論 3 335
  • 文/蒙蒙 一页屠、第九天 我趴在偏房一處隱蔽的房頂上張望粹胯。 院中可真熱鬧蓖柔,春花似錦、人聲如沸风纠。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,601評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)竹观。三九已至镐捧,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間臭增,已是汗流浹背懂酱。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,702評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留誊抛,地道東北人列牺。 一個(gè)月前我還...
    沈念sama閱讀 49,191評(píng)論 3 378
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像拗窃,于是被迫代替她去往敵國(guó)和親瞎领。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,781評(píng)論 2 361