Swift chaining syntax can be used to improve efficiency

FlowerCocoa

Swift chaining syntax can be used to improve efficiency

Method Link

UILabel

lazy var leLab: UILabel = {
  return UILabel().link
    .title(.text("FlowerCocoa"))
    .titleColor(.hex("#333333"))
    .alignment(.center)
    .font(.semibold(12))
    .base
}()

UIButton

lazy var button: UIButton = {
  return UIButton().link
    .stateNormal { $0.title("FlowerCocoa").color(.hex("#333333")) }
    .font(.semibold(12))
    .bgColor(.hex("#FFFFFF"))
    .borderColor(.hex("#999999"))
    .borderWidth(2)
    .cornerRadius(6)
    .base
}()

UIView

lazy var view: UIView = {
  return UIView().link
    .cornerRadius(6, masksToBounds: true)
    .borderWidth(1)
    .borderColor(.green)
    .base
}()

UIStackView

lazy var stackView: UIStackView = {
  return UIStackView().link
    .config(.horizontal, alignment: .fill, distribution: .fillEqually, spacing: 6)
    .arranged([tag1Lab, tag2Lab, tag3Lab])
    .base
}()

UITableView

lazy var tableView: UITableView = {
  return UITableView(frame: .zero, style: .plain)
    .link
    .separator(.none)
    .rowHeight(45)
    .footerView(UIView())
    .base
}()

UICollectionView

lazy var collectionView: UICollectionView = {
  let layout = UICollectionViewFlowLayout().link
    .scrollDirection(.vertical)
    .itemSize(.zero)
    .base
        
  return UICollectionView(frame: .zero, collectionViewLayout: layout).link
    .bgColor(.orange)
    .isScrollEnabled(false)
    .showsVerticalScrollIndicator(false)
    .showsHorizontalScrollIndicator(false)
    .base
}()

Extension

UIColor

view.link.bgColor(.rgb(33, 34, 35, 1))
view.link.bgColor(.hex("#FFFFFF"))
view.link.shadowColor(.hexCG("#FFFFFF"))

UIFont

label.link.font(.light(12))
button.link.font(.bold(22))

CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target 'MyApp' do
  pod FlowerCocoa'
end

GitHub

View Github