Skip to content
项目

mohn93/AdvancedPageControl

在 GitHub 查看

关于

适用于 iOS 的简洁而强大的动画页面控制指示器。

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
+1
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

AdvancedPageControl

Version License Platform

Buy Me A Coffee

A simple yet powerful page control indicator animations library for iOS, Written in Swift.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

AdvancedPageControl is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AdvancedPageControl'

Effects

  • Color Blend
  • Drop
  • ExtendedDot
  • Jump
  • Scale
  • Slide
  • Swap
  • Worm
  • ThinWorm
  • ThinWormHead
  • Scrolling
  • Infinite

Usage

I'm using it with expanded UICollectionView, create a collection view and link the DataSource and Delegate to your ViewController, and add UICollectionViewDeleageFlowLayout

class ViewController: UIViewController,
    UICollectionViewDataSource,
    UICollectionViewDelegate,
    UICollectionViewDelegateFlowLayout { ....

Then add these methods:

   func numberOfSections(in collectionView: UICollectionView) -> Int {
       return 5
   }
   
   func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
       return 1
   }
   
   func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
       return collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
   }
   
   
   func collectionView(_ collectionView: UICollectionView,
                       layout collectionViewLayout: UICollectionViewLayout,
                       sizeForItemAt indexPath: IndexPath) -> CGSize {
       return CGSize(width: collectionView.frame.width, height: 250) // This is to restric the item width and heigth to achive the single item preview
   }

Tick 'Scrolling enabled' and 'Paging enabled' Checkboxes in storyboard UICollectionView properties

Then add this method and pass the offset of the scrolling for UICollectionView, and width of the UICollectionView, to the pageControl , setCurrentItem, Method

func scrollViewDidScroll(_ scrollView: UIScrollView) {
      let offSet = scrollView.contentOffset.x
      let width = scrollView.frame.width
      
      pageControl.setPageOffset(offSet/width)
      
      // OR
      let index = Int(round(offSet/width))
      pageControl.setPage(index) // This will animate the page controll transition, whenever the index is changed, no need to pass an offset of every scroll offset

  }

Then set any drawer you like in viewDidLoad Method :

pageControl1.drawer = ColorBlendDrawer()

or you can pick one of these

ColorBlendDrawer()
DropDrawer()
ExtendedDotDrawer()
JumpDrawer()
ScaleDrawer()
SlideDrawer()
SwapDrawer()
ThinWormDrawer()
ThinWormHeadsDrawer()
WormDrawer()
Scrolling()
Infinite()

Alt Text

Customization

ScaleDrawer(numberOfPages:Int? = 5,
            height: CGFloat? = 16,
            width: CGFloat? = 16,
            space: CGFloat? = 16,
            radius: CGFloat? = 16,
            currentItem: CGFloat? = 0,
            indicatorColor: UIColor? = .red,
            dotsColor: UIColor? = .lightGray)

Author

Mohanned Binmiskeen, [email protected]

License

AdvancedPageControl is available under the MIT license. See the LICENSE file for more info.

探索相关项目

加载中…