Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3cc3d43b59 | |||
| 2e1748e25b | |||
| 847b88b3af | |||
| c987e11e77 | |||
| a6e3be745e | |||
| 96d3f40a48 | |||
| 7ffb2d3920 | |||
| 72ad3a47a5 | |||
| 8bccccb3f6 | |||
| 08b0761aff |
+1
-1
@@ -10,5 +10,5 @@ before_install:
|
||||
- gem install cocoapods # Since Travis is not always on latest version
|
||||
# - pod install --project-directory=Example
|
||||
script:
|
||||
- set -o pipefail && xcodebuild -workspace Example/ScalingCarousel.xcworkspace -scheme ScalingCarousel-Example -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=12.0,name=iPhone Xs' ONLY_ACTIVE_ARCH=NO | xcpretty
|
||||
- set -o pipefail && xcodebuild -workspace Example/ScalingCarousel.xcworkspace -scheme ScalingCarousel-Example -sdk iphonesimulator -destination 'platform=iOS Simulator,OS=13.0,name=iPhone 11' ONLY_ACTIVE_ARCH=NO | xcpretty
|
||||
- pod lib lint
|
||||
|
||||
+2
-2
@@ -401,7 +401,7 @@
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MARKETING_VERSION = 3.0;
|
||||
MARKETING_VERSION = 3.0.1;
|
||||
MODULEMAP_FILE = "Target Support Files/ScalingCarousel/ScalingCarousel.modulemap";
|
||||
PRODUCT_MODULE_NAME = ScalingCarousel;
|
||||
PRODUCT_NAME = ScalingCarousel;
|
||||
@@ -434,7 +434,7 @@
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MARKETING_VERSION = 3.0;
|
||||
MARKETING_VERSION = 3.0.1;
|
||||
MODULEMAP_FILE = "Target Support Files/ScalingCarousel/ScalingCarousel.modulemap";
|
||||
PRODUCT_MODULE_NAME = ScalingCarousel;
|
||||
PRODUCT_NAME = ScalingCarousel;
|
||||
|
||||
@@ -425,7 +425,7 @@
|
||||
INFOPLIST_FILE = ScalingCarousel/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MARKETING_VERSION = 3.0;
|
||||
MARKETING_VERSION = 3.0.1;
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -444,7 +444,7 @@
|
||||
INFOPLIST_FILE = ScalingCarousel/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MARKETING_VERSION = 3.0;
|
||||
MARKETING_VERSION = 3.0.1;
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
+10
-13
@@ -41,6 +41,15 @@
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "ScalingCarousel_Example.app"
|
||||
BlueprintName = "ScalingCarousel_Example"
|
||||
ReferencedContainer = "container:ScalingCarousel.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -53,17 +62,6 @@
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACCF1AFB9204008FA782"
|
||||
BuildableName = "ScalingCarousel_Example.app"
|
||||
BlueprintName = "ScalingCarousel_Example"
|
||||
ReferencedContainer = "container:ScalingCarousel.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
@@ -76,6 +74,7 @@
|
||||
debugDocumentVersioning = "YES"
|
||||
stopOnEveryThreadSanitizerIssue = "YES"
|
||||
stopOnEveryMainThreadCheckerIssue = "YES"
|
||||
migratedStopOnEveryIssue = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
@@ -88,8 +87,6 @@
|
||||
ReferencedContainer = "container:ScalingCarousel.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BY5-bO-M1j">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BY5-bO-M1j">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -39,7 +37,7 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RJs-7r-dhV">
|
||||
<rect key="frame" x="-0.5" y="0.0" width="50" height="50"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</subviews>
|
||||
@@ -66,14 +64,14 @@
|
||||
</connections>
|
||||
</collectionView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KAz-De-GJ8">
|
||||
<rect key="frame" x="150" y="105" width="74" height="30"/>
|
||||
<rect key="frame" x="150.5" y="85" width="74" height="30"/>
|
||||
<state key="normal" title="Show/Hide"/>
|
||||
<connections>
|
||||
<action selector="showHideButtonPressed:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="Jsy-vc-cWp"/>
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UYO-rO-XuZ">
|
||||
<rect key="frame" x="187" y="143" width="0.0" height="0.0"/>
|
||||
<rect key="frame" x="187.5" y="123" width="0.0" height="0.0"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
|
||||
@@ -102,6 +102,6 @@ extension CodeViewController: UICollectionViewDataSource {
|
||||
extension CodeViewController: UICollectionViewDelegate {
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
//scalingCarousel.didScroll()
|
||||
scalingCarousel.didScroll()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,10 @@ extension CarouselDatasource: UICollectionViewDataSource {
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
|
||||
|
||||
|
||||
if let scalingCell = cell as? ScalingCarouselCell {
|
||||
scalingCell.mainView.backgroundColor = .red
|
||||
scalingCell.cornerRadius = 40
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
@@ -74,7 +76,7 @@ typealias CarouselDelegate = StoryboardViewController
|
||||
extension StoryboardViewController: UICollectionViewDelegate {
|
||||
|
||||
func scrollViewDidScroll(_ scrollView: UIScrollView) {
|
||||
//carousel.didScroll()
|
||||
carousel.didScroll()
|
||||
|
||||
guard let currentCenterIndex = carousel.currentCenterCellIndex?.row else { return }
|
||||
|
||||
|
||||
@@ -34,13 +34,13 @@ This property is declared in ScalingCarouselCell. You should add any cell conten
|
||||
|
||||
* 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:)`):
|
||||
|
||||
```
|
||||
```swift
|
||||
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:
|
||||
|
||||
```
|
||||
```swift
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
scalingCarousel.deviceRotated()
|
||||
```
|
||||
@@ -49,7 +49,7 @@ scalingCarousel.deviceRotated()
|
||||
|
||||
* Create a custom UICollectionViewCell which inherits from ScalingCarouselCell. Initialize the mainView property, which is declared in ScalingCarouselCell;
|
||||
|
||||
```
|
||||
```swift
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
@@ -68,7 +68,7 @@ override init(frame: CGRect) {
|
||||
|
||||
* Create and add a ScalingCarouselView to your view, and implement the standard UICollectionViewDatasource methods in your view controller;
|
||||
|
||||
```
|
||||
```swift
|
||||
// Create our carousel
|
||||
let scalingCarousel = ScalingCarouselView(withFrame: frame, andInset: 20)
|
||||
scalingCarousel.dataSource = self
|
||||
@@ -92,13 +92,13 @@ scalingCarousel.topAnchor.constraint(equalTo: view.topAnchor, constant: 50).isAc
|
||||
|
||||
* 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:)`):
|
||||
|
||||
```
|
||||
```swift
|
||||
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:
|
||||
|
||||
```
|
||||
```swift
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
if scalingCarousel != nil {
|
||||
scalingCarousel.deviceRotated()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'ScalingCarousel'
|
||||
s.version = '3.0'
|
||||
s.version = '3.0.2'
|
||||
s.summary = 'A super simple carousel view with scaling transitions written in Swift'
|
||||
|
||||
s.description = <<-DESC
|
||||
|
||||
@@ -32,6 +32,9 @@ open class ScalingCarouselCell: UICollectionViewCell {
|
||||
/// The minimum value to alpha to, should be set between 0 and 1
|
||||
open var alphaMinimum: CGFloat = 0.85
|
||||
|
||||
/// The corner radius value of the cell's main view
|
||||
open var cornerRadius: CGFloat = 20.0
|
||||
|
||||
// MARK: - IBOutlets
|
||||
|
||||
// This property should be connected to the main cell subview
|
||||
@@ -87,6 +90,6 @@ open class ScalingCarouselCell: UICollectionViewCell {
|
||||
mainView.alpha = alphaValue
|
||||
|
||||
// ..also..round the corners
|
||||
mainView.layer.cornerRadius = 20
|
||||
mainView.layer.cornerRadius = cornerRadius
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ open class ScalingCarouselView: UICollectionView {
|
||||
private typealias PrivateAPI = ScalingCarouselView
|
||||
fileprivate extension PrivateAPI {
|
||||
|
||||
fileprivate func addInvisibleScrollView(to superview: UIView?) {
|
||||
func addInvisibleScrollView(to superview: UIView?) {
|
||||
guard let superview = superview else { return }
|
||||
|
||||
/// Add our 'invisible' scrollview
|
||||
@@ -215,7 +215,7 @@ fileprivate extension PrivateAPI {
|
||||
configureLayout()
|
||||
}
|
||||
|
||||
fileprivate func configureLayout() {
|
||||
func configureLayout() {
|
||||
|
||||
// Create a ScalingCarouselLayout using our inset
|
||||
collectionViewLayout = ScalingCarouselLayout(
|
||||
@@ -243,6 +243,11 @@ fileprivate extension PrivateAPI {
|
||||
// Activate the constraints
|
||||
invisibleWidthConstraint?.isActive = true
|
||||
invisibleLeftConstraint?.isActive = true
|
||||
|
||||
|
||||
// To avoid carousel moving when cell is tapped
|
||||
isPagingEnabled = true
|
||||
isScrollEnabled = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user