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

复制出来即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。