Skip to content

ikemai/ScaledVisibleCellsCollectionView

Repository files navigation

ScaledVisibleCellsCollectionView

CI Status Version License Platform

ScaledVisibleCellsCollectionView is UICollectionView extension. ScaledVisibleCellsCollectionView is Check visible cells position. And setting cell's scale and alpha.

Demo

Horizontal ( center / right / left )

Gif Gif Gif

Vertical ( center / top / bottom )

Gif Gif Gif

Usage

Cocoapods

To run the example project, clone the repo, and run pod install from the Example directory first. Add the following to your Podfile:

pod "ScaledVisibleCellsCollectionView"
use_frameworks!

Note: the use_frameworks! is required for pods made in Swift.

Example

  • Set propertis
let collectionView = UICollectionView(frame: view.bounds)
view.addSubview(collectionView)

collectionView.setScaledDesginParam(scaledPattern: .VerticalCenter, maxScale: 1.2, minScale: 0.5, maxAlpha: 1.0, minAlpha: 0.5)
  • Scale and alpha
func scrollViewDidScroll(scrollView: UIScrollView) {
	collectionView.scaledVisibleCells()
}

Variable

  • Set Scroll direction & position is the most large cell
var scaledPattern: SC_ScaledPattern = .VerticalCenter
public enum SC_ScaledPattern {
case HorizontalCenter
case HorizontalLeft
case HorizontalRight
case VerticalCenter
case VerticalBottom
case VerticalTop
}
  • Set Scale
var maxScale: CGFloat = 1.0
var minScale: CGFloat = 0.5
  • Set Alpha
var maxAlpha: CGFloat = 1.0
var minAlpha: CGFloat = 0.5

Function

  • Set property ( * Please always set )
func setScaledDesginParam(scaledPattern pattern: SC_ScaledPattern, maxScale: CGFloat, minScale: CGFloat, maxAlpha: CGFloat, minAlpha: CGFloat)
  • Set scale for visible cells ( * Please call at any time )
func scaledVisibleCells()

Author

ikemai

License

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