目录
目录README.md

LJTool

LJTool简介

在开发过程中,有一些常用扩展每次都会用到,每次拷贝来拷贝去,有点烦了,就封装成了一个工具库,使用pod来管理,方便多了。LJTool主要分成三大块:

  1. 配色类,封装了一些常用的颜色。
  2. 控件初始化,把控件的创建和常用的属性设置封装了一下,并且加了一些占位符
  3. 其它,包括图片的创建和button的内容排列方式

安装

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文件

lJTool

2. UI Create 可看demo中LJTool_UICreateViewController中的用法,创建完后默认会有占位符。

LJTool

  • UITableView
    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
    }()
  • CollectionView
    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
    }()
  • UILabel,推荐使用fontStyle方法,详情请查看Building Apps with Dynamic Type
    fileprivate lazy var userNameLabel: UILabel = {
      let label = UILabel.lj.label(textColor: UIColor.lj.text, fontStyle: UIFontTextStyle.headline)
      return label
    }()
  • UIImage
    fileprivate lazy var logoImageView: UIImageView = {
      let imageView = UIImageView.lj.imageView()
      return imageView
    }()
  • UIButton
    fileprivate lazy var commentButton: UIButton = {
      let button = UIButton.lj.button(title: "20", titleColor: UIColor.lj.gray999, fontSize: 14, image: #imageLiteral(resourceName: "icon_评论"))
      return button
    }()
  • UITextField
    fileprivate lazy var textField: UITextField = {
          let textField: UITextField = UITextField.lj.textField(placeholder: "placeholder", leftView: nil, rightView: nil)
          return textField
      }()
  1. 创建图片 创建图片主要有两个方法,一个是根据颜色值创建图片,一个是创建二维码图片

    let QRImage = UIImage.lj.QRImage("test")
    let colorImage = UIImage.lj.image(with: UIColor.red)
  2. UIButton 内容排列

    commentButton.lj.alignImageRightTitleLeft()
    collectionButton.lj.alignImageUpTitleDown()

    enter image description here

  3. 正则匹配

    string.lj.matchingRegExp("^\+?(?:[1-9]\d*(?:\.\d{1,2})?|0\.(?:\d[1-9]|[1-9]\d))
    quot;)

    联系我

    有好的建议或者反馈可发Issues

关于
230.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号