123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- //
- // TSPurchaseRroPageView.swift
- // TSLiveWallpaper
- //
- // Created by 100Years on 2025/8/20.
- //
- import TYCyclePagerView
- class TSPurchaseRroPageView : TSBaseView {
-
- var itemSize:CGSize = UIScreen.main.bounds.size
- lazy var models:[TSDiscoverItemModel] = [TSDiscoverItemModel](){
- didSet{
- itemSize = self.bounds.size
- pageControl.numberOfPages = models.count
- cyclePagerView.reloadData()
-
- kMainShort {
- guard let collectionView = self.cyclePagerView.collectionView else { return }
- }
- }
- }
-
- lazy var pageControl: TYPageControl = {
- let pageControl = TYPageControl()
- pageControl.currentPageIndicatorSize = CGSize(width: 20, height: 1)
- pageControl.pageIndicatorSize = CGSize(width: 20, height: 1)
- pageControl.currentPageIndicatorTintColor = .white
- pageControl.pageIndicatorTintColor = .white.withAlphaComponent(0.5)
- pageControl.pageIndicatorSpaing = 8
- pageControl.contentHorizontalAlignment = .center
- return pageControl
- }()
-
- lazy var cyclePagerView: TYCyclePagerView = {
- let pagerView = TYCyclePagerView()
- pagerView.isInfiniteLoop = true
- pagerView.autoScrollInterval = 5.0
- pagerView.delegate = self
- pagerView.dataSource = self
- pagerView.layout.layoutType = TYCyclePagerTransformLayoutType.linear
- pagerView.register(TSPurchaseRroPageViewCell.classForCoder(), forCellWithReuseIdentifier: "TSPurchaseRroPageViewCell")
- pagerView.addSubview(pageControl)
- pageControl.snp.makeConstraints { make in
- make.bottom.equalTo(-8)
- make.leading.equalTo(0)
- make.trailing.equalTo(0)
- make.height.equalTo(1)
- }
-
- return pagerView
- }()
- override func creatUI() {
-
-
-
- }
- }
- extension TSPurchaseRroPageView : TYCyclePagerViewDelegate, TYCyclePagerViewDataSource{
-
- func numberOfItems(in pageView: TYCyclePagerView) -> Int {
- return models.count
- }
-
- func pagerView(_ pagerView: TYCyclePagerView, cellForItemAt index: Int) -> UICollectionViewCell {
-
- if let itemModel = models.safeObj(At: index),
- let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "TSPurchaseRroPageViewCell", for: index) as? TSPurchaseRroPageViewCell
- {
- cell.model = itemModel
- return cell
- }
- return UICollectionViewCell()
- }
-
- func layout(for pageView: TYCyclePagerView) -> TYCyclePagerViewLayout {
- let layout = TYCyclePagerViewLayout()
- layout.itemSize = itemSize
- layout.itemSpacing = 0
- layout.itemHorizontalCenter = true
- layout.layoutType = .normal
- return layout
- }
- func pagerView(_ pageView: TYCyclePagerView, didSelectedItemCell cell: UICollectionViewCell, at index: Int) {
- }
-
- func pagerViewDidScroll(_ pageView: TYCyclePagerView) {
- }
-
- func pagerView(_ pageView: TYCyclePagerView, didScrollFrom fromIndex: Int, to toIndex: Int) {
- self.pageControl.currentPage = toIndex;
- }
- }
- class TSPurchaseRroPageViewCell: TSBaseCollectionCell {
- var model:TSDiscoverItemModel?
- override func creatUI() {
-
- }
- }
|