Compatibility
- 5.1.2 and master5.35.25.15.04.2
- 5.1.2 and masteriOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
开发中常用的工具方法
在开发过程中,有一些常用扩展每次都会用到,每次拷贝来拷贝去,有点烦了,就封装成了一个工具库,使用pod来管理,方便多了。LJTool主要分成三大块:
在Podfile
加入
pod 'LJTool'
然后执行下面命令即可
pod install
1. UIColor 类 根据RGB创建UIColor
UIColor.lj.color(r: 10, g: 10, b: 10)
根据16进制创建UIColor
UIColor.lj.color(0x123456, alpha: 1)
一些常用颜色的用法,查看LJColorViewController
文件
2. UI Create
可看demo中LJTool_UICreateViewController
中的用法,创建完后默认会有占位符。
fileprivate lazy var tableView: UITableView = {
let tableView: UITableView = UITableView.lj.tableView(dataSource: self, delegate: self)
tableView.backgroundColor = UIColor.lj.background
tableView.register(LJTableViewCell.self, forCellReuseIdentifier: kLJTableViewCell)
return tableView
}()
fileprivate lazy var imageCollectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
let collection = UICollectionView.lj.collectionView(layout: layout, dataSource: self, delegate: self)
collection.register(LJCollectionViewCell.self, forCellWithReuseIdentifier: kLJCollectionViewCell)
return collection
}()
fileprivate lazy var userNameLabel: UILabel = {
let label = UILabel.lj.label(textColor: UIColor.lj.text, fontStyle: UIFontTextStyle.headline)
return label
}()
fileprivate lazy var logoImageView: UIImageView = {
let imageView = UIImageView.lj.imageView()
return imageView
}()
fileprivate lazy var commentButton: UIButton = {
let button = UIButton.lj.button(title: "20", titleColor: UIColor.lj.gray999, fontSize: 14, image: #imageLiteral(resourceName: "icon_评论"))
return button
}()
fileprivate lazy var textField: UITextField = {
let textField: UITextField = UITextField.lj.textField(placeholder: "placeholder", leftView: nil, rightView: nil)
return textField
}()
let QRImage = UIImage.lj.QRImage("test")
let colorImage = UIImage.lj.image(with: UIColor.red)
commentButton.lj.alignImageRightTitleLeft()
collectionButton.lj.alignImageUpTitleDown()
string.lj.matchingRegExp("^\\+?(?:[1-9]\\d*(?:\\.\\d{1,2})?|0\\.(?:\\d[1-9]|[1-9]\\d))$")
有好的建议或者反馈可发Issues