1,协议
protocol UICollectionViewCartoonLayout : UICollectionViewDelegateFlowLayout {
func collection(_ collect:UICollectionView,layout collectionLayout : UICollectionViewFlowLayout,bg_colorForSection section : Int) -> UIColor
}
2,扩展
extension UICollectionViewCartoonLayout {
func collection(_ collect:UICollectionView,layout collectionLayout : UICollectionViewFlowLayout,bg_colorForSection section : Int) -> UIColor {
return collect.backgroundColor ?? UIColor.clear
}
}
3,block
public typealias ParallaxHeaderHandlerBlock = (_ parallaxHeader: ParallaxHeader)->Void
4,属性
public var minimumHeight: CGFloat = 0 {
didSet {
layoutContentView()
}
}
5,枚举
public enum HorizontalAlignment: Alignment {
case left
case justified
case right
}
6,全局汇总
var kScreenWidth = UIScreen.main.bounds.width
7,懒加载
lazy var detailConentVc : RZCartoonTabDetailViewController = {
let vc = RZCartoonTabDetailViewController()
vc.delegate = self
return vc
}()
8,解决适配问题
//MARK: SnapKit
extension ConstraintView {
/**解决iphoneX以后的底部和顶部安全距离*/
var snap: ConstraintBasicAttributesDSL {
if #available(iOS 11.0, *) {
return self.safeAreaLayoutGuide.snp
} else {
return self.snp
}
}
}
9 高斯模糊
addSubview(bgView)
bgView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
let blurEffect = UIBlurEffect(style: .dark)
blurView = UIVisualEffectView(effect: blurEffect)
bgView.addSubview(blurView)
blurView.snp.makeConstraints { (make) in
make.edges.equalToSuperview()
}
bgView.addSubview(coverView)