| | |
| | | |
| | | collectionView.emptyDataSetSource = self |
| | | collectionView.emptyDataSetDelegate = self |
| | | // collectionView.emptyDataSetView { v in |
| | | // let v = UIView() |
| | | // v.backgroundColor = .red |
| | | // |
| | | // return |
| | | // } |
| | | collectionView.emptyDataSetView { v in |
| | | |
| | | if let sub = v.viewWithTag(10010){ |
| | | |
| | | |
| | | }else{ |
| | | let v1 = UIView() |
| | | v1.tag = 10010 |
| | | v1.bounds = CGRect(x: 0, y: 0, width: 100, height: 100) |
| | | v1.center = CGPoint(x: v.center.x - 20, y: v.center.y - 150) |
| | | v.addSubview(v1) |
| | | |
| | | let image = UIImageView(image: UIImage(named: "icon_empty")) |
| | | image.contentMode = .scaleAspectFill |
| | | v1.addSubview(image) |
| | | image.snp.makeConstraints { make in |
| | | make.top.left.right.equalToSuperview() |
| | | } |
| | | |
| | | let label = UILabel(text: "暂未找到相关内容哦~") |
| | | label.font = .systemFont(ofSize: 14, weight: .medium) |
| | | label.textColor = .gray |
| | | v1.addSubview(label) |
| | | label.snp.makeConstraints { make in |
| | | make.centerX.equalTo(image) |
| | | make.top.equalTo(image.snp.bottom).offset(8) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | func setTitleItem(_ items:[TitleItem],defaultSelectIndex:Int = 0){ |
| | |
| | | } |
| | | |
| | | extension CourseMenuVC:EmptyDataSetSource{ |
| | | func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { |
| | | return UIImage(named: "icon_empty") |
| | | } |
| | | |
| | | func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? { |
| | | return AttributedStringbuilder.build().add(string: "暂无数据", withFont: .systemFont(ofSize: 12, weight: .medium), withColor: .gray).mutableAttributedString |
| | | } |
| | | |
| | | func verticalOffset(forEmptyDataSet scrollView: UIScrollView) -> CGFloat { |
| | | return 300 |
| | | } |
| | | |
| | | func spaceHeight(forEmptyDataSet scrollView: UIScrollView) -> CGFloat { |
| | | return 200 |
| | | } |
| | | //// func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? { |
| | | //// return UIImage(named: "icon_empty") |
| | | //// } |
| | | // |
| | | // func buttonBackgroundImage(forEmptyDataSet scrollView: UIScrollView, for state: UIControl.State) -> UIImage? { |
| | | // return UIImage(named: "icon_empty") |
| | | // } |
| | | // |
| | | // func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? { |
| | | // return AttributedStringbuilder.build().add(string: "暂无数据", withFont: .systemFont(ofSize: 12, weight: .medium), withColor: .gray).mutableAttributedString |
| | | // } |
| | | // |
| | | // func verticalOffset(forEmptyDataSet scrollView: UIScrollView) -> CGFloat { |
| | | // return 0 |
| | | // } |
| | | // |
| | | // func spaceHeight(forEmptyDataSet scrollView: UIScrollView) -> CGFloat { |
| | | // return 0 |
| | | // } |
| | | } |
| | | |
| | | extension CourseMenuVC:EmptyDataSetDelegate{ |