iOS 開發小記-02

最近又開始寫不少業務代碼了,有些小知識點小坑,用這個系列記錄一下。
iOS 開發小記-01
iOS 開發小記-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 輸入框縮進(使用 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 代碼觸發點擊事件

button.sendActions(for: .touchUpInside)

4. 導出 Xcode 代碼字體配色

Xcode 的配置字體樣式位于:

~/Library/Developer/Xcode/UserData/FontAndColorThemes

復制出來即可

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。