From 529f3c6b775dc75869f978f7403ac50c5343b4e4 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期五, 08 十一月 2024 21:34:06 +0800 Subject: [PATCH] fix bug --- XQMuse/Root/Course/VC/CourseMenuVC.swift | 69 ++++++++++++++++++++++++---------- 1 files changed, 48 insertions(+), 21 deletions(-) diff --git a/XQMuse/Root/Course/VC/CourseMenuVC.swift b/XQMuse/Root/Course/VC/CourseMenuVC.swift index 56a2a8d..ef7dc57 100644 --- a/XQMuse/Root/Course/VC/CourseMenuVC.swift +++ b/XQMuse/Root/Course/VC/CourseMenuVC.swift @@ -60,12 +60,35 @@ 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){ @@ -142,21 +165,25 @@ } 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{ -- Gitblit v1.7.1