diff --git a/Example/Default-568h@2x.png b/Example/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/Example/Default-568h@2x.png differ diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj index 008fd0a..f9dd855 100644 --- a/Example/Pods/Pods.xcodeproj/project.pbxproj +++ b/Example/Pods/Pods.xcodeproj/project.pbxproj @@ -301,7 +301,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0930; + TargetAttributes = { + E9582E7E712D7CD7A32DF86E8120CBC5 = { + LastSwiftMigration = 0930; + }; + }; }; buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; compatibilityVersion = "Xcode 3.2"; @@ -386,6 +391,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; @@ -441,6 +447,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -448,6 +455,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -478,6 +486,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = NO_SIGNING/; STRIP_INSTALLED_PRODUCT = NO; + SWIFT_COMPILATION_MODE = wholemodule; SYMROOT = "${SRCROOT}/../build"; }; name = Release; @@ -529,6 +538,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -536,6 +546,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -665,6 +676,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) "; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; diff --git a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ScalingCarousel.xcscheme b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ScalingCarousel.xcscheme index 1c3009c..0b34bc0 100644 --- a/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ScalingCarousel.xcscheme +++ b/Example/Pods/Pods.xcodeproj/xcshareddata/xcschemes/ScalingCarousel.xcscheme @@ -1,6 +1,6 @@ @@ -37,7 +36,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Example/Pods/Target Support Files/ScalingCarousel/Info.plist b/Example/Pods/Target Support Files/ScalingCarousel/Info.plist index f2381bb..d564912 100644 --- a/Example/Pods/Target Support Files/ScalingCarousel/Info.plist +++ b/Example/Pods/Target Support Files/ScalingCarousel/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.1 + 2.2 CFBundleSignature ???? CFBundleVersion diff --git a/Example/ScalingCarousel.xcodeproj/project.pbxproj b/Example/ScalingCarousel.xcodeproj/project.pbxproj index 414c349..9e51168 100644 --- a/Example/ScalingCarousel.xcodeproj/project.pbxproj +++ b/Example/ScalingCarousel.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; + 65678AFE206FEAF900A0ED42 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 65678AFD206FEAF900A0ED42 /* Default-568h@2x.png */; }; 65E99FA11E1519D50026BEC4 /* CodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E99FA01E1519D50026BEC4 /* CodeViewController.swift */; }; /* End PBXBuildFile section */ @@ -43,6 +44,7 @@ 607FACE51AFB9204008FA782 /* ScalingCarousel_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScalingCarousel_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; + 65678AFD206FEAF900A0ED42 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 659A02AC202F775500587C36 /* ScalingCarousel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScalingCarousel.h; sourceTree = ""; }; 659A02AD202F775500587C36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65E99FA01E1519D50026BEC4 /* CodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodeViewController.swift; sourceTree = ""; }; @@ -85,6 +87,7 @@ 607FACC71AFB9204008FA782 = { isa = PBXGroup; children = ( + 65678AFD206FEAF900A0ED42 /* Default-568h@2x.png */, 607FACF51AFB993E008FA782 /* Podspec Metadata */, 607FACD21AFB9204008FA782 /* Example */, 607FACE81AFB9204008FA782 /* Tests */, @@ -257,15 +260,17 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = 49CJ89TL4W; LastSwiftMigration = 0900; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; + DevelopmentTeam = 49CJ89TL4W; LastSwiftMigration = 0900; TestTargetID = 607FACCF1AFB9204008FA782; }; @@ -296,6 +301,7 @@ buildActionMask = 2147483647; files = ( 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, + 65678AFE206FEAF900A0ED42 /* Default-568h@2x.png in Resources */, 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, ); @@ -473,12 +479,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -526,12 +534,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -566,6 +576,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 49CJ89TL4W; INFOPLIST_FILE = ScalingCarousel/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -583,6 +594,7 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 49CJ89TL4W; INFOPLIST_FILE = ScalingCarousel/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -598,6 +610,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = BA63361010B0F437C40DBABF /* Pods-ScalingCarousel_Tests.debug.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 49CJ89TL4W; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -619,6 +632,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 2AC39C6CC3E82205FC41C768 /* Pods-ScalingCarousel_Tests.release.xcconfig */; buildSettings = { + DEVELOPMENT_TEAM = 49CJ89TL4W; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", diff --git a/Example/ScalingCarousel.xcodeproj/xcshareddata/xcschemes/ScalingCarousel-Example.xcscheme b/Example/ScalingCarousel.xcodeproj/xcshareddata/xcschemes/ScalingCarousel-Example.xcscheme index 01b9207..688af71 100644 --- a/Example/ScalingCarousel.xcodeproj/xcshareddata/xcschemes/ScalingCarousel-Example.xcscheme +++ b/Example/ScalingCarousel.xcodeproj/xcshareddata/xcschemes/ScalingCarousel-Example.xcscheme @@ -1,6 +1,6 @@ + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/ScalingCarousel/AppDelegate.swift b/Example/ScalingCarousel/AppDelegate.swift index 9ef1227..286631c 100644 --- a/Example/ScalingCarousel/AppDelegate.swift +++ b/Example/ScalingCarousel/AppDelegate.swift @@ -13,34 +13,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + return true } - - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - } diff --git a/Example/ScalingCarousel/Base.lproj/Main.storyboard b/Example/ScalingCarousel/Base.lproj/Main.storyboard index 7da84c2..769a37d 100644 --- a/Example/ScalingCarousel/Base.lproj/Main.storyboard +++ b/Example/ScalingCarousel/Base.lproj/Main.storyboard @@ -1,11 +1,12 @@ - + - + + @@ -13,10 +14,6 @@ - - - - @@ -86,12 +83,13 @@ - - - - + + + + + @@ -102,45 +100,41 @@ - + + + + + + + + + + + + + + + + + + + - - - - + - - - - - - - - - - - - - - - - - - - - + diff --git a/Example/ScalingCarousel/CodeViewController.swift b/Example/ScalingCarousel/CodeViewController.swift index 18bd82c..2553340 100644 --- a/Example/ScalingCarousel/CodeViewController.swift +++ b/Example/ScalingCarousel/CodeViewController.swift @@ -84,6 +84,6 @@ extension CodeViewController: UICollectionViewDataSource { extension CodeViewController: UICollectionViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { - scalingCarousel.didScroll() + //scalingCarousel.didScroll() } } diff --git a/Example/ScalingCarousel/Info.plist b/Example/ScalingCarousel/Info.plist index 1007fd9..13d16d7 100644 --- a/Example/ScalingCarousel/Info.plist +++ b/Example/ScalingCarousel/Info.plist @@ -15,10 +15,16 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.2 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + diff --git a/Example/ScalingCarousel/StoryboardViewController.swift b/Example/ScalingCarousel/StoryboardViewController.swift index 5dd866b..ea217fd 100644 --- a/Example/ScalingCarousel/StoryboardViewController.swift +++ b/Example/ScalingCarousel/StoryboardViewController.swift @@ -65,10 +65,24 @@ typealias CarouselDelegate = StoryboardViewController extension StoryboardViewController: UICollectionViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { - carousel.didScroll() + //carousel.didScroll() guard let currentCenterIndex = carousel.currentCenterCellIndex?.row else { return } output.text = String(describing: currentCenterIndex) } } + +private typealias ScalingCarouselFlowDelegate = StoryboardViewController +extension ScalingCarouselFlowDelegate: UICollectionViewDelegateFlowLayout { + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { + + return 0 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + + return 0 + } +} diff --git a/ScalingCarousel.podspec b/ScalingCarousel.podspec index 56b34e8..7548c11 100644 --- a/ScalingCarousel.podspec +++ b/ScalingCarousel.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'ScalingCarousel' - s.version = '2.1' + s.version = '2.2' s.summary = 'A super simple carousel view with scaling transitions written in Swift' s.description = <<-DESC diff --git a/ScalingCarousel/Classes/ScalingCarouselCell.swift b/ScalingCarousel/Classes/ScalingCarouselCell.swift index 81f4e26..5482741 100644 --- a/ScalingCarousel/Classes/ScalingCarouselCell.swift +++ b/ScalingCarousel/Classes/ScalingCarouselCell.swift @@ -20,16 +20,23 @@ import UIKit */ open class ScalingCarouselCell: UICollectionViewCell { + // MARK: - Properties (Public) + + /// The minimum value to scale to, should be set between 0 and 1 + open var scaleMinimum: CGFloat = 0.9 + + /// Divisior used when calculating the scale value. + /// Lower values cause a greater difference in scale between subsequent cells. + open var scaleDivisor: CGFloat = 10.0 + + /// The minimum value to alpha to, should be set between 0 and 1 + open var alphaMinimum: CGFloat = 0.85 + // MARK: - IBOutlets // This property should be connected to the main cell subview @IBOutlet public var mainView: UIView! - private struct InternalConstants { - static let alphaSmallestValue: CGFloat = 0.85 - static let scaleDivisor: CGFloat = 10.0 - } - // MARK: - Overrides override open func layoutSubviews() { @@ -49,10 +56,7 @@ open class ScalingCarouselCell: UICollectionViewCell { /// Scale the cell when it is scrolled /// /// - parameter carouselInset: The inset of the related SPBCarousel view - /// - parameter scaleMinimum: The minimun % a cell should scale to, - /// expressed as a value between 0.0 and 1.0 - open func scale(withCarouselInset carouselInset: CGFloat, - scaleMinimum: CGFloat = 0.9) { + open func scale(withCarouselInset carouselInset: CGFloat) { // Ensure we have a superView, and mainView guard let superview = superview, @@ -71,10 +75,10 @@ open class ScalingCarouselCell: UICollectionViewCell { let percentageScale = (scaleCalculator/width) let scaleValue = scaleMinimum - + (percentageScale/InternalConstants.scaleDivisor) + + (percentageScale/scaleDivisor) - let alphaValue = InternalConstants.alphaSmallestValue - + (percentageScale/InternalConstants.scaleDivisor) + let alphaValue = alphaMinimum + + (percentageScale/scaleDivisor) let affineIdentity = CGAffineTransform.identity