最近又開(kāi)始寫不少業(yè)務(wù)代碼了,有些小知識(shí)點(diǎn)小坑,用這個(gè)系列記錄一下。
iOS 開(kāi)發(fā)小記-01
iOS 開(kāi)發(fā)小記-02
1. UIView 添加虛線邊框 Dash Line
let dashBorderLayer = CAShapeLayer()
let path = UIBezierPath(roundedRect: holderView.bounds, cornerRadius: 4)
dashBorderLayer.path = path.cgPath
dashBorderLayer.strokeColor = Color.lightGreyText.withAlphaComponent(0.4).cgColor
dashBorderLayer.lineDashPattern = [3, 3]
dashBorderLayer.backgroundColor = UIColor.clear.cgColor
dashBorderLayer.fillColor = UIColor.clear.cgColor
holderView.layer.addSublayer(dashBorderLayer)
2. UITextField 輸入框縮進(jìn)(使用 leftView)
let textFieldLeftView = UIView(frame: CGRect(x: 0, y: 0, width: 12, height: 10))
textFieldLeftView.backgroundColor = UIColor.clear
missionNameTextField.leftView = textFieldLeftView
missionNameTextField.leftViewMode = .always
missionNameTextField.contentVerticalAlignment = .center
3. UIButton 代碼觸發(fā)點(diǎn)擊事件
button.sendActions(for: .touchUpInside)
4. 導(dǎo)出 Xcode 代碼字體配色
Xcode 的配置字體樣式位于:
~/Library/Developer/Xcode/UserData/FontAndColorThemes
復(fù)制出來(lái)即可