Skip to content

CoderHuiYu/MMAdvertScrollView

Repository files navigation

MMAdvertScrollView

一个轻量级、简单易用的公告轮播组件

2981628157219_

The realization principle of cyclic rolling

collectionView has 2 sections

start --> indexPath(0, 0) --> indexPath(1, 0) --> indexPath(2, 0) --> ... --> indexPath(n-1, 0) --> indexPath(0, 1) --> indexPath(1, 0)--> indexPath(2, 0)

MMadverstScrollView

image & gif:

1.How to use MMAdvertScrollView

  • Installation with CocoaPods:pod 'MMAdvertScrollView', '~> 1.2.1'
 var timeInterval: TimeInterval = 3.0 // 滚动间隔默认为3秒
 var scrollDirection: UICollectionView.ScrollDirection = .vertical //默认滚动方向为竖向

You can use like this

 let m1 = MMAdvertScrollView(frame: CGRect(x: 0, y: 135, width: UIScreen.main.bounds.width, height: 40))
 m1.dataArray = ["恭喜xx,完成了数据管理能力测评。" ,"恭喜xxxxxxxxxxxxxx,完成实名认证。"]
 view.addSubview(m1)

2.This framework supports custom views

public protocol MMAdvertScrollCustomerViewDelegate: AnyObject{

    func customerViewDataArrayCount() -> Int
    func customViewConfigure(numberOfItems item: Int, cycleView view: MMAdvertScrollView) -> UIView
    func collectionView(_ cycleView: MMAdvertScrollView, didSelectItemAt indexItem: Int) 
    
}

you can refer to CustomerView

extension CustomerView: MMAdvertScrollCustomerViewDelegate {
    func customViewConfigure(numberOfItems item: Int, cycleView view: MMAdvertScrollView) -> UIView {
        let view = VipView()
        view.title = dataArray[item]
        return view
    }

    func customerViewDataArrayCount() -> Int {
        return dataArray.count
    }
}

Remind

  • ARC
  • iOS>=11.0

If you have any questions

If you have any questions, you can email to me:171364980@qq.com

About

一个简单、轻量级的swift版公告轮播框架

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published