Commit e3ece8c5 authored by David黄金龙's avatar David黄金龙

删除 不使用的代码

parent e4c90cff
This diff is collapsed.
//
// YHDavidTestViewController.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
import ESPullToRefresh
import JXSegmentedView
import GKNavigationBarSwift
class YHDavidTestViewController: YHBaseViewController {
var vcCanScroll : Bool = true
lazy var descripeLable:UILabel = {
let label = UILabel()
label.text = "赴港攻略,当日往返无忧,这个季节风景..赴港攻略,当日往返无忧,这个季节风景"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
label.numberOfLines = 2
label.lineBreakMode = .byTruncatingTail
return label
}()
lazy var headImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_person_icon"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var nameLable:UILabel = {
let label = UILabel()
label.text = "Fiona"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
return label
}()
lazy var dateLable:UILabel = {
let label = UILabel()
label.text = "12-12"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
return label
}()
lazy var heartImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_red_heart"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var numLable:UILabel = {
let label = UILabel()
label.text = "2000"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 14)
return label
}()
lazy var items = {
return [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "")]
}()
private lazy var bannerView: YHHomeBannerView = {
let view = YHHomeBannerView()
return view
}()
lazy var myCollectView = {
// 设置布局方向
let flowLayout = UICollectionViewFlowLayout()
let margin = 20.0
let gap = 20.0
let itemWidth = ceil((KScreenWidth - 2*margin - gap)/2.0)
flowLayout.itemSize = CGSize(width: itemWidth, height: 210 + 87 + 4)
flowLayout.minimumInteritemSpacing = 10.0
flowLayout.minimumLineSpacing = 10.0
flowLayout.scrollDirection = .vertical
let collectinoView = YHGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.contentInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
collectinoView.backgroundColor = .white
collectinoView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectinoView.register(YHDavidTestCollectionViewCell.self, forCellWithReuseIdentifier:YHDavidTestCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
return collectinoView
}()
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
view.backgroundColor = .white
gk_navigationBar.isHidden = true
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "")]
self.myCollectView.reloadData()
}
}
extension YHDavidTestViewController {
private func loadFirstItem() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items = [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: "")]
self.myCollectView.es.stopPullToRefresh(ignoreDate: true,ignoreFooter: false)
self.myCollectView.reloadData()
}
}
private func loadFakeData() {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.items.append(AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""))
self.myCollectView.es.stopLoadingMore()
self.myCollectView.reloadData()
}
}
func setupUI() {
gk_navTitle = "David的测试UI"
view.backgroundColor = .white
view.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.top.equalToSuperview().offset(10)
}
self.myCollectView.es.addInfiniteScrolling {
self.loadFakeData()
}
}
}
extension YHDavidTestViewController: UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHDavidTestCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHDavidTestCollectionViewCell
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
}
// MARK: - JXSegmentedListContainerViewListDelegate
extension YHDavidTestViewController: JXSegmentedListContainerViewListDelegate {
func listView() -> UIView {
return view
}
}
// MARK: - 滑动使用
extension YHDavidTestViewController: UIScrollViewDelegate {
//控制滑动交互
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let scrollViewSet: CGFloat = scrollView.contentOffset.y
if vcCanScroll == false {//不能滚动时
scrollView.contentOffset = CGPoint(x: -20, y: 0)
} else {
if (scrollViewSet <= 0) {
scrollView.contentOffset = CGPoint(x: -20, y: 0)
vcCanScroll = false
NotificationCenter.default.post(name: Notification.Name(rawValue: "leaveTop"), object: nil)
} else {
scrollView.contentOffset = CGPoint(x: -20, y: scrollViewSet)
}
}
}
}
//
// ContentBaseViewController.swift
// JXSegmentedView
//
// Created by jiaxin on 2018/12/26.
// Copyright © 2018 jiaxin. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHMainContentBaseViewController: UIViewController {
var canScroll : Bool = false {
didSet {
for vc in arrItemVCs {
vc.vcCanScroll = canScroll
}
}
}
let arrItemTitles = ["推荐","子女教育","税务规划","民生医疗","成功案例","我的服务","行业资讯","香港生活","你我他","我是很长的tag呀"]
var arrItemVCs : [YHDavidTestViewController] = []
var segmentedView : JXSegmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 40))
lazy var segmentedDataSource: JXSegmentedBaseDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.isTitleColorGradientEnabled = true
dataSource.titles = arrItemTitles
dataSource.titleNormalFont = UIFont.PFSC_M(ofSize: 16)
dataSource.titleNormalColor = .labelTextColor2
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 18)
dataSource.titleSelectedColor = .brandMainColor
dataSource.isItemSpacingAverageEnabled = false
dataSource.itemWidth = JXSegmentedViewAutomaticDimension
dataSource.itemSpacing = 24
return dataSource
}()
//分类title 所对应的VC
lazy var listContainerView: JXSegmentedListContainerView! = {
return JXSegmentedListContainerView(dataSource: self, type: .collectionView)
}()
override func viewDidLoad() {
super.viewDidLoad()
for _ in arrItemTitles {
let vc = YHDavidTestViewController()
arrItemVCs.append(vc)
}
//segmentedViewDataSource一定要通过属性强持有!!!!!!!!!
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
view.addSubview(segmentedView)
segmentedView.listContainer = listContainerView
view.addSubview(listContainerView)
//分类Title
segmentedView.dataSource = segmentedDataSource
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorColor = .blue
segmentedView.indicators = [indicator]
segmentedView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//处于第一个item的时候,才允许屏幕边缘手势返回
navigationController?.interactivePopGestureRecognizer?.isEnabled = (segmentedView.selectedIndex == 0)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//离开页面的时候,需要恢复屏幕边缘手势,不能影响其他页面
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
segmentedView.frame = CGRect(x: 0, y: 0, width: view.bounds.size.width, height: 50)
listContainerView.frame = CGRect(x: 0, y: 50, width: view.bounds.size.width, height: view.bounds.size.height - 50)
}
}
extension YHMainContentBaseViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewDidEndDragging"), object: nil)
}
/// 正在滚动中的回调
///
/// - Parameters:
/// - segmentedView: JXSegmentedView
/// - leftIndex: 正在滚动中,相对位置处于左边的index
/// - rightIndex: 正在滚动中,相对位置处于右边的index
/// - percent: 从左往右计算的百分比
func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
NotificationCenter.default.post(name: Notification.Name(rawValue: "scrollViewWillBeginDragging"), object: nil)
}
}
extension YHMainContentBaseViewController: JXSegmentedListContainerViewDataSource {
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
return titleDataSource.dataSource.count
}
return 0
}
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
return arrItemVCs[index]
}
}
//
// YHBbxCollectionViewCell.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHBbxCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHBbxCollectionViewCell"
static let bbxCellHeight = 64
static let bbxCellWidth = 80
lazy var titleImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_bbx_icon"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var descripeLable:UILabel = {
let label = UILabel()
label.textColor = UIColor(red: 0.315, green: 0.315, blue: 0.315, alpha: 1)
label.font = UIFont.PFSC_R(ofSize: 12)
label.textAlignment = .center
label.text = "证件办理"
// label.backgroundColor = .blue
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
contentView.addSubview(titleImageView)
titleImageView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.height.width.equalTo(44)
make.centerX.equalToSuperview()
}
contentView.addSubview(descripeLable)
descripeLable.snp.makeConstraints { make in
make.top.equalTo(titleImageView.snp.bottom).offset(4)
make.centerX.equalToSuperview()
make.height.equalTo(16)
make.left.right.equalToSuperview()
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell0: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell0"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var headImage: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.image = UIImage(named: "home_cell0_head_icon")
return imagV
}()
lazy var contentImage: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleAspectFill
imagV.image = UIImage(named: "home_cell0_content_icon")
return imagV
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(headImage)
contentView.addSubview(contentImage)
contentImage.snp.makeConstraints { make in
make.top.equalToSuperview().offset(12)
make.right.equalToSuperview().offset(-16)
make.width.equalTo(242)
make.height.equalTo(97)
}
headImage.snp.makeConstraints { make in
make.right.equalTo(contentImage.snp.left)
make.width.equalTo(88)
make.height.equalTo(122)
make.bottom.equalToSuperview()
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell1: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell1"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var bigImageView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleToFill
imagV.image = UIImage(named: "home_cell1_bkg")
return imagV
}()
lazy var subContentView : UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x999999, alpha: 1.0)
view.layer.cornerRadius = kCornerRadius6
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(182)
}
subContentView.addSubview(bigImageView)
bigImageView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(182)
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell2: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell2"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var bigImageView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleToFill
imagV.image = UIImage(named: "home_cell1_bkg")
return imagV
}()
lazy var subContentView : UIView = {
let view = UIView()
view.backgroundColor = UIColor(hex: 0x999999, alpha: 1.0)
view.layer.cornerRadius = kCornerRadius6
view.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
view.layer.cornerRadius = 10
view.layer.borderWidth = 0.5
view.layer.borderColor = UIColor(red: 0.862, green: 0.862, blue: 0.862, alpha: 1).cgColor
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(16)
make.right.equalTo(-16)
make.height.equalTo(99)
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell3: UITableViewCell {
static let cellReuseIdentifier = "YHDavidCell3"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var bigImageView: UIImageView = {
let imagV = UIImageView()
imagV.contentMode = .scaleToFill
imagV.image = UIImage(named: "home_cell1_bkg")
return imagV
}()
lazy var subContentView : UIView = {
let view = UIView()
view.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(138)
}
let bbxLable = UILabel()
bbxLable.text = "银河推荐官"
bbxLable.textColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
bbxLable.font = UIFont.PFSC_R(ofSize: 18)
subContentView.addSubview(bbxLable)
bbxLable.snp.makeConstraints { make in
make.top.equalTo(13)
make.left.equalTo(25)
}
let desLable = UILabel()
desLable.text = "邀请拉新,合作共赢"
desLable.frame = CGRect(x: 0, y: 0, width: 141.5, height: 11.5)
desLable.textColor = UIColor(red: 0.592, green: 0.592, blue: 0.592, alpha: 1)
desLable.font = UIFont.PFSC_R(ofSize: 10)
subContentView.addSubview(desLable)
desLable.snp.makeConstraints { make in
make.left.equalTo(bbxLable.snp.right).offset(11)
make.centerY.equalTo(bbxLable)
}
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import FSPagerView
class YHDavidCell4: UITableViewCell {
fileprivate var dataArr: [YHBannerModel] = [YHBannerModel(),YHBannerModel(),YHBannerModel(),YHBannerModel(),YHBannerModel()]
static let cellHeight : CGFloat = 88 + 20
static let cellReuseIdentifier = "YHDavidCell4"
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var subContentView : UIView = {
let view = UIView()
// view.backgroundColor = .red
return view
}()
private lazy var bannerView: FSPagerView = {
let view = FSPagerView()
view.delegate = self
view.dataSource = self
view.automaticSlidingInterval = 2
view.register(FSPagerViewCell.self, forCellWithReuseIdentifier: "cell")
view.itemSize = FSPagerView.automaticSize
view.interitemSpacing = 10
view.isInfinite = true
return view
}()
lazy var pageControl: FSPageControl = {
let view = FSPageControl()
return view
}()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.left.equalTo(16)
make.right.equalTo(-16)
make.bottom.equalToSuperview()
}
subContentView.addSubview(bannerView)
bannerView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.height.equalTo(80)
}
subContentView.addSubview(pageControl)
pageControl.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(bannerView.snp.bottom)
make.height.equalTo(20)
}
setupPageControl()
bannerView.reloadData()
}
func setupPageControl() {
self.pageControl.numberOfPages = self.dataArr.count
self.pageControl.contentHorizontalAlignment = .center
let normalImage = UIImage(color: .white, size: CGSize(width: 15, height: 5))
let selectImage = UIImage(color: UIColor(hex: 0xff0000, alpha: 1.0), size: CGSize(width: 20, height: 5))
self.pageControl.setImage(normalImage, for: .normal)
self.pageControl.setImage(selectImage, for: .selected)
self.pageControl.interitemSpacing = 15
}
}
// MARK: - FSPagerViewDelegate
extension YHDavidCell4: FSPagerViewDataSource, FSPagerViewDelegate {
public func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.dataArr.count
}
public func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
let image = UIImage(named: "default_placeholder_image")?.bs_scaled(toWidth: UIDevice.kScreenW - 16*2, opaque: false)
cell.imageView?.image = image
if index < dataArr.count {
let model = dataArr[index]
if let url = URL(string: model.img_url) {
cell.imageView?.kf.setImage(with: url)
}
// cell.textLabel?.text = model.title
}
cell.imageView?.contentMode = .scaleAspectFill
cell.backgroundColor = .contentBkgColor
cell.contentView.layer.shadowColor = UIColor.clear.cgColor
return cell
}
func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
self.pageControl.currentPage = targetIndex
}
func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
self.pageControl.currentPage = pagerView.currentIndex
}
}
//
// YHDavidCell0.swift
// galaxy
//
// Created by davidhuangA on 2024/1/17.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHDavidCell5: UITableViewCell {
static let cellHeight : CGFloat = 219
static let cellReuseIdentifier = "YHDavidCell5"
let items : [Int32] = [1,2,3,4,5,6,7,8]
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
setupUI()
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
lazy var subContentView : UIView = {
let view = UIView()
view.backgroundColor = .white
return view
}()
var myCollectView : UICollectionView!
// lazy var myCollectView = {
// // 设置布局方向
//
//
//
// return collectinoView
// }()
func setupUI() {
contentView.backgroundColor = .clear
backgroundColor = .clear
contentView.addSubview(subContentView)
subContentView.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
let bbxLable = UILabel()
bbxLable.text = "百宝箱"
bbxLable.textColor = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1)
bbxLable.font = UIFont.PFSC_R(ofSize: 18)
subContentView.addSubview(bbxLable)
bbxLable.snp.makeConstraints { make in
make.top.equalTo(13)
make.left.equalTo(25)
}
let desLable = UILabel()
desLable.text = "香港本地宝,智慧小助手"
desLable.frame = CGRect(x: 0, y: 0, width: 141.5, height: 11.5)
desLable.textColor = UIColor(red: 0.592, green: 0.592, blue: 0.592, alpha: 1)
desLable.font = UIFont.PFSC_R(ofSize: 10)
subContentView.addSubview(desLable)
desLable.snp.makeConstraints { make in
make.left.equalTo(bbxLable.snp.right).offset(11)
make.centerY.equalTo(bbxLable)
}
// subContentView.backgroundColor = UIColor(hex: 0x999999)
let flowLayout = UICollectionViewFlowLayout()
let margin = 16.0
let gap = 20.0
let itemWidth = 80.0
flowLayout.itemSize = CGSize(width: itemWidth, height: 64)
flowLayout.minimumInteritemSpacing = (KScreenWidth - 2 * 16 - 2*16 - 4 * itemWidth)/4
flowLayout.minimumLineSpacing = 15.0
flowLayout.scrollDirection = .vertical
let collectinoView = YHGestureCollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectinoView.contentInset = UIEdgeInsets(top: 0, left: margin, bottom: 20, right: margin)
collectinoView.backgroundColor = .white
collectinoView.register(YHBbxCollectionViewCell.self, forCellWithReuseIdentifier:YHBbxCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
myCollectView = collectinoView
myCollectView.isScrollEnabled = false
subContentView.addSubview(myCollectView)
myCollectView.snp.makeConstraints { make in
make.top.equalTo(bbxLable.snp.bottom).offset(15)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.bottom.equalToSuperview().offset(-20)
}
}
}
extension YHDavidCell5: UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHBbxCollectionViewCell.cellReuseIdentifier, for: indexPath) as! YHBbxCollectionViewCell
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
}
//
// YHDavidTestCollectionViewCell.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
class YHDavidTestCollectionViewCell: UICollectionViewCell {
static let cellReuseIdentifier = "YHDavidTestCollectionViewCell"
lazy var titleImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "start_page_bkg"))
imageV.contentMode = .scaleAspectFill
imageV.roundCorners(UIRectCorner.topLeft, radius: 8)
imageV.roundCorners(UIRectCorner.topRight, radius: 8)
return imageV
}()
lazy var descripeLable:UILabel = {
let label = UILabel()
label.text = "赴港攻略,当日往返无忧,这个季节风景..赴港攻略,当日往返无忧,这个季节风景"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
label.numberOfLines = 2
label.lineBreakMode = .byTruncatingTail
return label
}()
lazy var headImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_person_icon"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var nameLable:UILabel = {
let label = UILabel()
label.text = "Fiona"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
return label
}()
lazy var dateLable:UILabel = {
let label = UILabel()
label.text = "12-12"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 10)
return label
}()
lazy var heartImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_red_heart"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var numLable:UILabel = {
let label = UILabel()
label.text = "2000"
label.textColor = UIColor(hexString:"#333333")
label.font = UIFont.systemFont(ofSize: 14)
return label
}()
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
private func setupUI() {
contentView.backgroundColor = UIColor(hexString: "#F8F9FB")
contentView.roundCorners([.topLeft,.topRight], radius: 4)
contentView.clipsToBounds = true
contentView.addSubview(titleImageView)
titleImageView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(210)
}
let subHoldView = UIView()
subHoldView.layer.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor
subHoldView.layer.borderWidth = 0.5
subHoldView.layer.borderColor = UIColor(red: 0.798, green: 0.798, blue: 0.798, alpha: 1).cgColor
contentView.addSubview(subHoldView)
subHoldView.snp.makeConstraints { make in
make.top.equalTo(titleImageView.snp.bottom).offset(4)
make.left.right.equalToSuperview()
make.height.equalTo(87)
}
subHoldView.addSubview(descripeLable)
descripeLable.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8)
make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8)
make.height.equalTo(30)
}
subHoldView.addSubview(headImageView)
headImageView.snp.makeConstraints { make in
make.top.equalTo(descripeLable.snp.bottom).offset(10)
make.left.equalTo(descripeLable.snp.left)
make.height.width.equalTo(25)
}
subHoldView.addSubview(nameLable)
nameLable.snp.makeConstraints { make in
make.top.equalTo(headImageView.snp.top)
make.left.equalTo(headImageView.snp.right).offset(5)
make.height.equalTo(12)
make.width.equalTo(50)
}
subHoldView.addSubview(dateLable)
dateLable.snp.makeConstraints { make in
make.top.equalTo(nameLable.snp.bottom).offset(2)
make.left.equalTo(nameLable.snp.left)
make.height.equalTo(12)
make.right.equalTo(nameLable.snp.right)
}
subHoldView.addSubview(numLable)
numLable.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8)
make.height.equalTo(12)
make.centerY.equalTo(headImageView.snp.centerY)
}
subHoldView.addSubview(heartImageView)
heartImageView.snp.makeConstraints { make in
make.right.equalTo(numLable.snp.left).offset(-6)
make.height.width.equalTo(12)
make.centerY.equalTo(headImageView.snp.centerY)
}
}
}
......@@ -18,11 +18,6 @@ extension YHGestureTableView: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
// open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// return true
// }
}
......@@ -38,11 +33,6 @@ extension YHGestureScrollView: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
// open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// return true
// }
}
......@@ -57,9 +47,4 @@ extension YHGestureCollectionView: UIGestureRecognizerDelegate {
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
// open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
// return true
// }
}
//
// YHHomeCustomCell.swift
// galaxy
//
// Created by davidhuangA on 2024/1/10.
// Copyright © 2024 www.davidhuang.com. All rights reserved.
//
import UIKit
class YHHomeCustomCell: UITableViewCell {
static let cellReuseIdentifier = "YHHomeCustomCell"
lazy var items = {
return [AboutAdvantageItem(iconName: "about_match", title: "精准匹配", detail: "大数据精准匹配,专属方案获批率更高", url: ""),
AboutAdvantageItem(iconName: "about_response", title: "快速响应", detail: "身份规划师一对一专业服务,第一时间响应您的需求", url: ""),
AboutAdvantageItem(iconName: "about_service", title: "专业服务", detail: "5年经验+英语专8级文案导师团队倾力支持", url: ""),
AboutAdvantageItem(iconName: "about_service2", title: "精准匹配", detail: "香港专才、香港留学获批常年保持90%以上", url: "")]
}()
var dataArray: [String] = [] // 假定我们的数据结构就是一个String数组
var collectionView: UICollectionView!
var collectionContainer: UIView!
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// 设置布局方向
let flowLayout = UICollectionViewFlowLayout()
let margin = 18.0
let gap = 12.0
let itemWidth = floor((KScreenWidth-2*margin-gap)/2.0)
flowLayout.itemSize = CGSize(width: itemWidth, height: itemWidth)
flowLayout.minimumInteritemSpacing = 12.0
flowLayout.minimumLineSpacing = 12.0
flowLayout.scrollDirection = .vertical
collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
collectionView.contentInset = UIEdgeInsets(top: 0, left: margin, bottom: 0, right: margin)
collectionView.backgroundColor = UIColor.white
collectionView.register(YHAboutUsAdvantageCell.self, forCellWithReuseIdentifier:YHAboutUsAdvantageCell.cellReuseIdentifier)
collectionView.delegate = self
collectionContainer = UIView(frame: .zero)
contentView.addSubview(collectionContainer)
collectionContainer.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.height.equalTo(0)
}
collectionContainer.addSubview(collectionView)
collectionView.snp.makeConstraints({ make in
make.edges.equalToSuperview()
})
// collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "test")
// collectionView.delegate = self // 这里根据具体业务写吧,demo中我就把代理直接设置成cell了..
// collectionView.dataSource = self // 根据业务,demo直接先cell持有数据来控制collectionView的显示了..
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// 外部调用,用来设置collectionView的数据源
func setData(_ data: [String]) {
self.dataArray = data
collectionView.reloadData()
// 这里需要 layoutIfNeeded 一下,否则我们不能同步拿到contentSize
// 注意,如果上面collectionContainer的布局没有指明宽度,这个时候cell的宽度是estimate状态,所以下面就算layout也拿不到正确的contentSize
collectionView.layoutIfNeeded()
let height = collectionView.contentSize.height
printLog(height)
collectionContainer.snp.updateConstraints { make in
make.height.equalTo(height)
}
}
}
extension YHHomeCustomCell: UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return items.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: YHAboutUsAdvantageCell.cellReuseIdentifier, for: indexPath) as! YHAboutUsAdvantageCell
cell.advantateItem = items[indexPath.row]
return cell
}
private func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print("index is \(indexPath.row)")
}
}
//
// YHHomeViewController.swift
// YHServiceCenterMainViewController.swift
// galaxy
//
// Created by EDY on 2023/12/20.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment