版权声明:最短的时间最核心的知识,有疑问,欢迎进行留言。 https://blog.csdn.net/lizhidefengzi/article/details/83869335
常用控件设置
- UILable
- UIButton
- UITableViewController
- 常用宏设置
UILabel
常见设置:
- 设置换行
- 设置对齐方式
lazy private var messageTitleLabel: UILabel = {
let label = UILabel()
label.textColor = UIColor.black
label.backgroundColor = .clear
label.textAlignment = NSTextAlignmentCenter;
label.font = UIFont.systemFont(ofSize: 10)
label.numberOfLines = 0
return label
}()
UIButton
常见设置:
- 设置圆角、边框样式
- 设置图片与标题相对位置
lazy private var button: UIButton = {
let button = UIButton(type: .custom)
button.backgroundColor = .clear
button.setTitle("详情", for: .normal)
button.imageEdgeInsets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 50)
button.titleEdgeInsets = UIEdgeInsets.init(top: 0, left: -50, bottom: 0, right: 0)
button.setTitleColor(.orange, for: .normal)
button.titleLabel?.font = UIFont.systemFont(ofSize: 10)
copyButton.layer.cornerRadius = 10
copyButton.layer.masksToBounds = true
copyButton.layer.borderColor = UIColor.orange.cgColor
copyButton.layer.borderWidth = 1.0
return button
}()
UITableViewController
常见设置问题
- UITableViewCell重用
- 取消分割线,取消点击跳转
- 设置右侧细节
- 添加分割线,行之间距离(默认没有方法,添加对应view视图即可)
self.selectionStyle = .none
self.tableView.separatorStyle = .none
self.tableView.register(WMCommunitySendCodeTableViewCell.self, forCellReuseIdentifier: "cell")
常用宏设置
- 颜色设置
- 相对距离设置
func RGB(r: CGFloat, g: CGFloat, b: CGFloat, alpha: CGFloat) -> UIColor {
return UIColor (red: r/225.0, green: g/225.0, blue: b/225.0, alpha: alpha)
}
func kScale(_ num: CGFloat) -> CGFloat {
return num * screenWidth / 375
}
生命周期
ios开发生命周期分UIViewController生命周期和App的生命周期,掌握的意义在于熟悉程序的执行过程。
生命周期