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