{"id":14110819,"url":"https://github.com/aataraxiaa/ScalingCarousel","last_synced_at":"2025-08-01T11:31:08.262Z","repository":{"id":15140742,"uuid":"68836160","full_name":"aataraxiaa/ScalingCarousel","owner":"aataraxiaa","description":"A super simple carousel view with scaling transitions written in Swift","archived":false,"fork":false,"pushed_at":"2021-11-02T17:33:23.000Z","size":16596,"stargazers_count":757,"open_issues_count":5,"forks_count":98,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-11-28T20:50:02.560Z","etag":null,"topics":["carousel","ios","iphone","mobile","swift","uicollectionview"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aataraxiaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-21T16:25:48.000Z","updated_at":"2024-11-24T01:30:52.000Z","dependencies_parsed_at":"2022-07-19T05:47:03.930Z","dependency_job_id":null,"html_url":"https://github.com/aataraxiaa/ScalingCarousel","commit_stats":null,"previous_names":["aataraxiaa/scalingcarousel","superpeteblaze/scalingcarousel"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aataraxiaa%2FScalingCarousel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aataraxiaa%2FScalingCarousel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aataraxiaa%2FScalingCarousel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aataraxiaa%2FScalingCarousel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aataraxiaa","download_url":"https://codeload.github.com/aataraxiaa/ScalingCarousel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228369565,"owners_count":17909279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["carousel","ios","iphone","mobile","swift","uicollectionview"],"created_at":"2024-08-14T10:03:00.587Z","updated_at":"2024-12-05T20:31:21.057Z","avatar_url":"https://github.com/aataraxiaa.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# ScalingCarousel\n\n[![CI Status](http://img.shields.io/travis/superpeteblaze/ScalingCarousel.svg?style=flat)](https://travis-ci.org/superpeteblaze/ScalingCarousel)\n[![Version](https://img.shields.io/cocoapods/v/ScalingCarousel.svg?style=flat)](http://cocoapods.org/pods/ScalingCarousel)\n[![License](https://img.shields.io/cocoapods/l/ScalingCarousel.svg?style=flat)](http://cocoapods.org/pods/ScalingCarousel)\n[![Platform](https://img.shields.io/cocoapods/p/ScalingCarousel.svg?style=flat)](http://cocoapods.org/pods/ScalingCarousel)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)\n\nScalingCarousel provides a simple carousel-style collection view.\nIt takes care of cell presentation, scaling each cell as the collection view is scrolled.\n\nIt is used in [Bikey](https://itunes.apple.com/ie/app/bikey/id1048962300?mt=8) to present bike station information, as seen below;\n\n![Bikey ScalingCarousel example](Images/BikeyExample.gif)\n\n## Usage\n\nScalingCarousel can be added via both storyboard/xib and code, as described below.\n\n### Storyboard\n\n* Add a UICollectionView to your view, and change the type to ScalingCarouselView\n\n* In the attributes inspector, set the desired carousel inset\n\n* Set your UIViewController as the collection view datasource and implement the standard UICollectionViewDatasource methods in your view controller\n\n* Set your UIViewController as the collection view delegate and implement the UIScrollViewDelegate method scrollViewDidScroll(:). In this method, call the didScroll() method of ScalingCarouselView\n\n* Create a custom UICollectionViewCell which inherits from ScalingCarouselCell, and set the cell type to your custom cell type in the storyboard\n\n* 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.\nThis property is declared in ScalingCarouselCell. You should add any cell content to this view.\n\n* 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:)`):\n\n```swift\ncell.setNeedsLayout()\ncell.layoutIfNeeded()\n```\n* 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:\n\n```swift\nsuper.viewWillTransition(to: size, with: coordinator)\nscalingCarousel.deviceRotated()\n```\n\n### Code\n\n* Create a custom UICollectionViewCell which inherits from ScalingCarouselCell. Initialize the mainView property, which is declared in ScalingCarouselCell;\n\n```swift\noverride init(frame: CGRect) {\n  super.init(frame: frame)\n\n  // Initialize the mainView property and add it to the cell's contentView\n  mainView = UIView(frame: contentView.bounds)\n  contentView.addSubview(mainView)\n  mainView.translatesAutoresizingMaskIntoConstraints = false\n  NSLayoutConstraint.activate([\n      mainView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),\n      mainView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),\n      mainView.topAnchor.constraint(equalTo: contentView.topAnchor),\n      mainView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor)\n  ])\n}\n```\n\n* Create and add a ScalingCarouselView to your view, and implement the standard UICollectionViewDatasource methods in your view controller;\n\n```swift\n// Create our carousel\nlet scalingCarousel = ScalingCarouselView(withFrame: frame, andInset: 20)\nscalingCarousel.dataSource = self\nscalingCarousel.delegate = self\nscalingCarousel.translatesAutoresizingMaskIntoConstraints = false\n\n// Register our custom cell for dequeueing\nscalingCarousel.register(Cell.self, forCellWithReuseIdentifier: \"cell\")\n\n// Add our carousel as a subview        \nview.addSubview(scalingCarousel)\n\n// Add Constraints\nscalingCarousel.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 1).isActive = true\nscalingCarousel.heightAnchor.constraint(equalToConstant: 300).isActive = true\nscalingCarousel.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true\nscalingCarousel.topAnchor.constraint(equalTo: view.topAnchor, constant: 50).isActive = true\n```\n\n* Set your UIViewController as the collection view delegate and implement the UIScrollViewDelegate method scrollViewDidScroll(:). In this method, call the didScroll() method of ScalingCarouselView\n\n* 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:)`):\n\n```swift\ncell.setNeedsLayout()\ncell.layoutIfNeeded()\n```\n* 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:\n\n```swift\nsuper.viewWillTransition(to: size, with: coordinator)\nif scalingCarousel != nil {\n    scalingCarousel.deviceRotated()\n}\n\n```\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Requirements\n\niOS 10\n\n## Installation\n\nScalingCarousel is available through [CocoaPods](http://cocoapods.org), [Carthage](https://github.com/Carthage/Carthage) and [Swift Package Manager](https://swift.org/package-manager/).\n\nTo install via Cocoapods, add the following line to your Podfile:\n\n```ruby\npod \"ScalingCarousel\"\n```\n\nTo install via Carthage, add the following line to your Podfile:\n\n```\ngithub \"superpeteblaze/ScalingCarousel\"\n```\n\nTo install via Swift package manager:\n\n\u003e Note: Instructions below are for using **SwiftPM** without the Xcode UI. It's the easiest to go to your Project Settings -\u003e Swift Packages and add ScalingCarousel from there.\n\nTo integrate using Apple's Swift package manager, without Xcode integration, add the following as a dependency to your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/superpeteblaze/ScalingCarousel.git\", .upToNextMajor(from: \"3.2.0\"))\n```\n## Author\n\nPete Smith, peadar81@gmail.com\n\n## License\n\nScalingCarousel is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faataraxiaa%2FScalingCarousel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faataraxiaa%2FScalingCarousel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faataraxiaa%2FScalingCarousel/lists"}