All Projects → superpeteblaze → Scalingcarousel

superpeteblaze / Scalingcarousel

Licence: mit
A super simple carousel view with scaling transitions written in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Scalingcarousel

React Items Carousel
Items Carousel Built with react-motion and styled-components
Stars: ✭ 150 (-69.94%)
Mutual labels:  mobile, carousel
Streetmusicmap
StreetMusicMap is a collab line up of street music performers from all over the world.
Stars: ✭ 13 (-97.39%)
Mutual labels:  iphone, mobile
Slider
Touch swipe image slider/slideshow/gallery/carousel/banner mobile responsive bootstrap
Stars: ✭ 2,046 (+310.02%)
Mutual labels:  mobile, carousel
Egjs Flicking
🎠 ♻️ Everyday 30 million people experience. It's reliable, flexible and extendable carousel.
Stars: ✭ 937 (+87.78%)
Mutual labels:  mobile, carousel
Carlenscollectionviewlayout
An easy-to-use Collection View Layout for card-like animation.
Stars: ✭ 478 (-4.21%)
Mutual labels:  iphone, uicollectionview
Embla Carousel
A lightweight carousel library with fluid motion and great swipe precision.
Stars: ✭ 1,874 (+275.55%)
Mutual labels:  mobile, carousel
Gravityslider
🔄 GravitySlider is a beautiful alternative to the standard UICollectionView flow layout.
Stars: ✭ 784 (+57.11%)
Mutual labels:  iphone, uicollectionview
Keen Slider
The HTML touch slider carousel with the most native feeling
Stars: ✭ 3,097 (+520.64%)
Mutual labels:  mobile, carousel
Uicollectionviewsplitlayout
UICollectionViewSplitLayout makes collection view more responsive.
Stars: ✭ 226 (-54.71%)
Mutual labels:  iphone, uicollectionview
Texture Compressor
CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container.
Stars: ✭ 156 (-68.74%)
Mutual labels:  iphone, mobile
Swiper
Most modern mobile touch slider with hardware accelerated transitions
Stars: ✭ 29,519 (+5815.63%)
Mutual labels:  mobile, carousel
Open Source Xamarin Apps
📱 Collaborative List of Open Source Xamarin Apps
Stars: ✭ 318 (-36.27%)
Mutual labels:  iphone, mobile
Centeredcollectionview
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎡 written in Swift
Stars: ✭ 965 (+93.39%)
Mutual labels:  carousel, uicollectionview
React Responsive Carousel
React.js Responsive Carousel (with Swipe)
Stars: ✭ 1,962 (+293.19%)
Mutual labels:  mobile, carousel
Gmimagepicker.xamarin
Port of the original GMImagePicker component to Xamarin.iOS
Stars: ✭ 65 (-86.97%)
Mutual labels:  iphone, mobile
Yampa
Functional Reactive Programming domain-specific language embedded in Haskell, for programming efficient hybrid (mixed discrete-time and continuous-time) systems.
Stars: ✭ 294 (-41.08%)
Mutual labels:  iphone, mobile
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (-18.84%)
Mutual labels:  mobile, carousel
Cp Design
A configurable Mobile UI Components(React hooks+Typescript+Scss)组件库
Stars: ✭ 465 (-6.81%)
Mutual labels:  mobile
Kddraganddropcollectionview
This component allows for the transfer of data items between collection views through drag and drop
Stars: ✭ 476 (-4.61%)
Mutual labels:  uicollectionview
Hexo Theme Yilia Plus
一个简洁优雅的hexo主题 A simple and elegant theme for hexo.
Stars: ✭ 462 (-7.41%)
Mutual labels:  mobile

ScalingCarousel

CI Status Version License Platform Carthage compatible Swift Package Manager compatible

ScalingCarousel provides a simple carousel-style collection view. It takes care of cell presentation, scaling each cell as the collection view is scrolled.

It is used in Bikey to present bike station information, as seen below;

Bikey ScalingCarousel example

Usage

ScalingCarousel can be added via both storyboard/xib and code, as described below.

Storyboard

  • Add a UICollectionView to your view, and change the type to ScalingCarouselView

  • In the attributes inspector, set the desired carousel inset

  • Set your UIViewController as the collection view datasource and implement the standard UICollectionViewDatasource methods in your view controller

  • Set your UIViewController as the collection view delegate and implement the UIScrollViewDelegate method scrollViewDidScroll(:). In this method, call the didScroll() method of ScalingCarouselView

  • Create a custom UICollectionViewCell which inherits from ScalingCarouselCell, and set the cell type to your custom cell type in the storyboard

  • Add a view to the cell's content view, and connect this via the Connections Inspector (in Interface builder) to the cell's mainView IBOutlet. This property is declared in ScalingCarouselCell. You should add any cell content to this view.

  • Note: To ensure correct scaling of the ScalingCarouselCell, you need to call the following code after you configure your cell with it's data (e.g in cellForItem(at:)):

cell.setNeedsLayout()
cell.layoutIfNeeded()
  • Note: To ensure correct displayed of the ScalingCarousel, you need to call the following code in the method viewWillTransition(to size:, with coordinator:) of the ViewController:
super.viewWillTransition(to: size, with: coordinator)
scalingCarousel.deviceRotated()

Code

  • Create a custom UICollectionViewCell which inherits from ScalingCarouselCell. Initialize the mainView property, which is declared in ScalingCarouselCell;
override init(frame: CGRect) {
  super.init(frame: frame)

  // Initialize the mainView property and add it to the cell's contentView
  mainView = UIView(frame: contentView.bounds)
  contentView.addSubview(mainView)
  mainView.translatesAutoresizingMaskIntoConstraints = false
  NSLayoutConstraint.activate([
      mainView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
      mainView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
      mainView.topAnchor.constraint(equalTo: contentView.topAnchor),
      mainView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)
  ])
}
  • Create and add a ScalingCarouselView to your view, and implement the standard UICollectionViewDatasource methods in your view controller;
// Create our carousel
let scalingCarousel = ScalingCarouselView(withFrame: frame, andInset: 20)
scalingCarousel.dataSource = self
scalingCarousel.delegate = self
scalingCarousel.translatesAutoresizingMaskIntoConstraints = false

// Register our custom cell for dequeueing
scalingCarousel.register(Cell.self, forCellWithReuseIdentifier: "cell")

// Add our carousel as a subview        
view.addSubview(scalingCarousel)

// Add Constraints
scalingCarousel.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1).isActive = true
scalingCarousel.heightAnchor.constraint(equalToConstant: 300).isActive = true
scalingCarousel.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
scalingCarousel.topAnchor.constraint(equalTo: view.topAnchor, constant: 50).isActive = true
  • Set your UIViewController as the collection view delegate and implement the UIScrollViewDelegate method scrollViewDidScroll(:). In this method, call the didScroll() method of ScalingCarouselView

  • Note: To ensure correct scaling of the ScalingCarouselCell, you need to call the following code after you configure your cell with it's data (e.g in cellForItem(at:)):

cell.setNeedsLayout()
cell.layoutIfNeeded()
  • Note: To ensure correct displayed of the ScalingCarousel, you need to call the following code in the method viewWillTransition(to size:, with coordinator:) of the ViewController, If you have created the ScalingCarousel by code in the viewDidLoad, It is important to verify that it exists when the method viewWillTransition is called or we will have a crash if we load the viewController with the device in landscape mode:
super.viewWillTransition(to: size, with: coordinator)
if scalingCarousel != nil {
    scalingCarousel.deviceRotated()
}

Example

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

Requirements

iOS 10

Installation

ScalingCarousel is available through CocoaPods, Carthage and Swift Package Manager.

To install via Cocoapods, add the following line to your Podfile:

pod "ScalingCarousel"

To install via Carthage, add the following line to your Podfile:

github "superpeteblaze/ScalingCarousel"

To install via Swift package manager:

Note: Instructions below are for using SwiftPM without the Xcode UI. It's the easiest to go to your Project Settings -> Swift Packages and add ScalingCarousel from there.

To integrate using Apple's Swift package manager, without Xcode integration, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/superpeteblaze/ScalingCarousel.git", .upToNextMajor(from: "3.2.0"))

Author

Pete Smith, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].