IOS基础控件思维导图
image-20200729192506800.png
二、中级控件
1、UIStepper
(1)常用属性
open var value: Double
open var minimumValue: Double
open var maximumValue: Double
open var stepValue: Double //default = 1
open var isContinuous: Bool//default = YES
open var wraps: Bool // 是否首尾相接
(2)常用方法
func addTarget(self,#selector(youract),for:UIControlEvent) //万能方法
//一对
open func setBackgroundImage(_ image: UIImage?, for state: UIControl.State)
open func backgroundImage(for state: UIControl.State) -> UIImage?
//一对,分割线
/*Stepper样子:
_________
| - | + |
---------
*/
open func setDividerImage(_ image: UIImage?, forLeftSegmentState leftState: UIControl.State, rightSegmentState rightState: UIControl.State)
open func dividerImage(forLeftSegmentState state: UIControl.State, rightSegmentState state: UIControl.State) -> UIImage?
//一对
open func setIncrementImage(_ image: UIImage?, for state: UIControl.State)
open func incrementImage(for state: UIControl.State) -> UIImage?
//一对
open func setDecrementImage(_ image: UIImage?, for state: UIControl.State)
open func decrementImage(for state: UIControl.State) -> UIImage?
2、UISlider
(1)常用属性
open var value: Float
open var minimumValue: Float
open var maximumValue: Float
open var minimumValueImage: UIImage?
open var maximumValueImage: UIImage?
open var isContinuous: Bool // if set, value change events are generated any time the value changes due to dragging. default = YES
open var minimumTrackTintColor: UIColor?
open var maximumTrackTintColor: UIColor?
open var thumbTintColor: UIColor?
open func thumbImage(for state: UIControl.State) -> UIImage?
open func minimumTrackImage(for state: UIControl.State) -> UIImage?
open func maximumTrackImage(for state: UIControl.State) -> UIImage?
(2)常用方法
func addTarget(self,#selector(youract),for:UIControlEvent)
3、UIPickerView-->UIPickerViewDelegate,UIPickViewDataSource
(1)常用属性
**weak open var dataSource: UIPickerViewDataSource?
**weak open var delegate: UIPickerViewDelegate?
open var numberOfComponents: Int { get }
open func numberOfRows(inComponent component: Int) -> Int
open func rowSize(forComponent component: Int) -> CGSize
(2)代理方法
optional func pickerView(_ pickerView: UIPickerView, widthForComponent component: Int) -> CGFloat
optional func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat
optional func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?
optional func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString?
optional func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView
optional func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
(3)数据集方法
func numberOfComponents(in pickerView: UIPickerView) -> Int
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int
4、UIDataPicker
(1)常用属性
open var datePickerMode: UIDatePicker.Mode
open var date: Date // default is current date when picker created. Ignored in countdown timer mode. for that mode, picker starts at 0:00
open var minimumDate: Date? // specify min/max date range. default is nil. When min > max, the values are ignored. Ignored in countdown timer mode
open var maximumDate: Date? // default is nil
(2)常用方法
open func setDate(_ date: Date, animated: Bool)
5、UIActivityIndicatorViewUI
(1)常用属性
open var style: UIActivityIndicatorView.Style // default is UIActivityIndicatorViewStyleMedium
open var hidesWhenStopped: Bool // default is YES. calls -setHidden when animating gets set to NO
open var color: UIColor!
(2)常用方法
open func startAnimating()
open func stopAnimating()
6、UISearchBar-->UISearchBarDelegate
(1)常用属性
**weak open var delegate: UISearchBarDelegate? // weak reference.
open var text: String? // current/starting search text
open var placeholder: String? // default is nil
//搜索栏标题,在搜索栏中上位置
open var prompt: String? // default is nil
open var barTintColor: UIColor? // default is nil
open var searchBarStyle: UISearchBar.Style
open var backgroundImage: UIImage?
————————————————————————————————————————————————————————————————————————————————
//书签按钮(右
open var showsBookmarkButton: Bool // default is NO
//取消按钮
open var showsCancelButton: Bool // default is NO
//历史记录按钮
open var showsSearchResultsButton: Bool // default is NO
//自定义按钮的图标,其中第二个参数指明按钮的类型(search,bookmark,cancel,searchresult)
open func setImage(_ iconImage: UIImage?, for icon: UISearchBar.Icon, state: UIControl.State)
————————————————————————————————————————————————————————————————————————————————
//附件视图
open var showsScopeBar: Bool
//附件视图的按钮名字
open var scopeButtonTitles: [String]?
//当前所在按钮
open var selectedScopeButtonIndex: Int
(2)代理方法
optional func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool
optional func searchBarTextDidBeginEditing(_ searchBar: UISearchBar)
optional func searchBarShouldEndEditing(_ searchBar: UISearchBar) -> Bool
optional func searchBarTextDidEndEditing(_ searchBar: UISearchBar)
————————————————————————————————————————————————————————————————————————————————
optional func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String)
optional func searchBar(_ searchBar: UISearchBar, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool
————————————————————————————————————————————————————————————————————————————————
optional func searchBarSearchButtonClicked(_ searchBar: UISearchBar)
optional func searchBarBookmarkButtonClicked(_ searchBar: UISearchBar)
optional func searchBarCancelButtonClicked(_ searchBar: UISearchBar)
optional func searchBarResultsListButtonClicked(_ searchBar: UISearchBar)
————————————————————————————————————————————————————————————————————————————————
//附件视图按钮改变
optional func searchBar(_ searchBar: UISearchBar,selectedScopeButtonIndexDidChange selectedScope: Int)
7、UIProgressView
(1)常用属性
open var progressViewStyle: UIProgressView.Style
//当前进度,默认是0.0,范围是0.0 ~ 1.0
open var progress: Float
(2)常用方法
//进度颜色
open var progressTintColor: UIColor?
//轨道颜色
open var trackTintColor: UIColor?
open var progressImage: UIImage?
open var trackImage: UIImage?
网友评论