美文网首页
IOS开发(一)基础控件

IOS开发(一)基础控件

作者: 涛子_024d | 来源:发表于2020-08-09 11:45 被阅读0次

IOS基础控件思维导图

image-20200729192506800.png

1、UILable

(1)常用属性


open var text: String? // default is nil

open var font: UIFont! // default is nil (system font 17 plain)

open var textColor: UIColor! // default is labelColor

open var textAlignment: NSTextAlignment

2、UIImageView

public init(image: UIImage?, highlightedImage: UIImage?)

3、UIButton

(1)常用属性

var backgroudColor:UIColor

(2)常用方法

open func setTitle(_ title: String?, for state: UIControl.State) 
open func setTitleColor(_ color: UIColor?, for state: UIControl.State)
open func setImage(_ image: UIImage?, for state: UIControl.State) 
open func setBackgroundImage(_ image: UIImage?, for state: UIControl.State)
func addTarget(self,action:#selector(yourfunc),for:UIControlEvent)

4、UITextField—>UITextFieldDelegate

(1)常用属性

open var text: String?
open var textColor: UIColor? 
open var font: UIFont? 
open var textAlignment: NSTextAlignment 
open var borderStyle: UITextField.BorderStyle 
open var placeholder: String? 
open var leftView: UIView? 
open var rightView: UIView?
weak open var delegate: UITextFieldDelegate? 

(2)代理方法

 func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool 

 func textFieldDidBeginEditing(_ textField: UITextField)

 func textFieldShouldEndEditing(_ textField: UITextField) -> Bool 

 func textFieldDidEndEditing(_ textField: UITextField) 

 func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) 
//文本发生变化时调用
 func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool 
    
 func textFieldDidChangeSelection(_ textField: UITextField)

 func textFieldShouldClear(_ textField: UITextField) -> Bool

 func textFieldShouldReturn(_ textField: UITextField) -> Bool

5、UISwitch

(1)常用属性

//开启状态的颜色
open var onTintColor: UIColor?
//正常(未开启)状态的颜色
open var TintColor: UIColor?
//开关的滑块颜色
open var thumbTintColor: UIColor?

open var onImage: UIImage?

open var offImage: UIImage?
//当前状态
open var isOn: Bool

(2)常用方法

func addTarget(self,#selector(youract),for:UIControlEvent)

6、UIPageControl

(1)常用属性

    open var numberOfPages: Int 

    open var currentPage: Int 
        //其他未选中的页码点的颜色
    open var pageIndicatorTintColor: UIColor?
        //当前选中的页码点的颜色
    open var currentPageIndicatorTintColor: UIColor?


(2)常用方法

func addTarget(self,#selector(youract),for:UIControlEvent)

7、UISegmentedController

(1)常用属性

open var isMomentary: Bool // if set, then we don't keep showing selected state after tracking ends. default is NO

open var selectedSegmentIndex: Int

@available(iOS 13.0, *)
open var selectedSegmentTintColor: UIColor?

(2)常用方法

//构造方法指定每个segment显示的对象,创建的时候必须指定
public init(items: [Any]?) 

func addTarget(self,#selector(youract),for:UIControlEvent)

//title
open func setTitle(_ title: String?, forSegmentAt segment: Int)

open func titleForSegment(at segment: Int) -> String?

//Image
open func setImage(_ image: UIImage?, forSegmentAt segment: Int) 

open func imageForSegment(at segment: Int) -> UIImage?

//width
open func setWidth(_ width: CGFloat, forSegmentAt segment: Int)

open func widthForSegment(at segment: Int) -> CGFloat

//CGSize
open func setContentOffset(_ offset: CGSize, forSegmentAt segment: Int) 

open func contentOffsetForSegment(at segment: Int) -> CGSize

    
open func setEnabled(_ enabled: Bool, forSegmentAt segment: Int) 

open func isEnabledForSegment(at segment: Int) -> Bool

//remove and insert
open func insertSegment(withTitle title: String?, at segment: Int, animated: Bool)

open func insertSegment(with image: UIImage?, at segment: Int, animated: Bool)

open func removeSegment(at segment: Int, animated: Bool)

open func removeAllSegments()
        

相关文章

网友评论

      本文标题:IOS开发(一)基础控件

      本文链接:https://www.haomeiwen.com/subject/xwkurktx.html