|
@@ -10,23 +10,57 @@ import UIKit
|
|
|
|
|
|
class PublishFilterView: BaseView {
|
|
|
|
|
|
- override func setupViews() {
|
|
|
- self.backgroundColor = kf7f8faColor
|
|
|
-
|
|
|
+ typealias DimClickClosure = () -> Void
|
|
|
+ var dimClickClosure : DimClickClosure?
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ addSubview(dimBackView)
|
|
|
addSubview(collectionView)
|
|
|
+ addSubview(titleLabel)
|
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
|
- collectionView.snp.remakeConstraints { (make) in
|
|
|
- make.top.equalTo(10)
|
|
|
- make.bottom.equalTo(-10)
|
|
|
+ dimBackView.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
+ collectionView.snp.makeConstraints { (make) in
|
|
|
+ make.height.equalTo(125)
|
|
|
+ make.bottom.equalTo(-kSafeTabBarHeight)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ }
|
|
|
+ titleLabel.snp.makeConstraints { (make) in
|
|
|
+ make.height.equalTo(48)
|
|
|
+ make.bottom.equalTo(collectionView.snp_top)
|
|
|
make.left.right.equalToSuperview()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private lazy var dimBackView: UIView = {
|
|
|
+ let dimBackView = UIView()
|
|
|
+ dimBackView.backgroundColor = kRGBAColor(r: 0/255.0, g: 0/255.0, b: 0/255.0, a: 0.2)
|
|
|
+ dimBackView.addTapGesture(1, target: self, action: #selector(dismissAction))
|
|
|
+ return dimBackView
|
|
|
+ }()
|
|
|
+ /// 内容详情页面
|
|
|
+ @objc func dismissAction() {
|
|
|
+ if let dimClickClosure = self.dimClickClosure {
|
|
|
+ dimClickClosure()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private lazy var titleLabel: UILabel = {
|
|
|
+ let titleLabel = UILabel()
|
|
|
+ titleLabel.backgroundColor = kRGBAColor(r: 0/255.0, g: 0/255.0, b: 0/255.0, a: 0.2)
|
|
|
+ titleLabel.text = "滤镜"
|
|
|
+ titleLabel.textColor = kffffffColor
|
|
|
+ titleLabel.font = kRegularFont16
|
|
|
+ titleLabel.textAlignment = .center
|
|
|
+ return titleLabel
|
|
|
+ }()
|
|
|
+
|
|
|
private lazy var collectionView: UICollectionView = {
|
|
|
let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
|
|
|
- collectionView.backgroundColor = kf7f8faColor
|
|
|
+ collectionView.backgroundColor = kRGBAColor(r: 0/255.0, g: 0/255.0, b: 0/255.0, a: 0.5)
|
|
|
collectionView.delegate = self;
|
|
|
collectionView.dataSource = self;
|
|
|
collectionView.showsVerticalScrollIndicator = false
|
|
@@ -36,28 +70,11 @@ class PublishFilterView: BaseView {
|
|
|
}()
|
|
|
|
|
|
private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
|
|
|
- let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
|
|
|
- collectionViewLayout.minimumLineSpacing = 10
|
|
|
- collectionViewLayout.minimumInteritemSpacing = 10
|
|
|
- collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.horizontal
|
|
|
- collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 3*10)/4, height: 24)
|
|
|
+ let collectionViewLayout = UICollectionViewFlowLayout.init()
|
|
|
+ collectionViewLayout.minimumInteritemSpacing = 15
|
|
|
+ collectionViewLayout.scrollDirection = .horizontal
|
|
|
return collectionViewLayout
|
|
|
}()
|
|
|
-
|
|
|
- //加载数据
|
|
|
- func reloadData() {
|
|
|
- //collectionView重新加载数据
|
|
|
- self.collectionView.reloadData()
|
|
|
- //更新collectionView的高度约束
|
|
|
- let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
|
|
|
- collectionView.snp.makeConstraints { (make) in
|
|
|
- make.top.equalTo(10)
|
|
|
- make.bottom.equalTo(-10)
|
|
|
- make.left.right.equalToSuperview()
|
|
|
- make.height.equalTo(contentSize.height)
|
|
|
- }
|
|
|
- self.collectionView.collectionViewLayout.invalidateLayout()
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
extension PublishFilterView: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
|
|
@@ -74,6 +91,10 @@ extension PublishFilterView: UICollectionViewDelegateFlowLayout,UICollectionView
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
+ func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
|
+ return CGSize(width:52, height: 80)
|
|
|
+ }
|
|
|
+
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
|
|
|
return UIEdgeInsets(top: 0, left: 14, bottom: 0, right: 14)
|
|
|
}
|