11 Commits

Author SHA1 Message Date
Pete Smith 7bc09a4947 Bump version 2018-05-28 10:37:34 +04:00
Pete Smith e2e0a59efc Merge pull request #39 from pabsanmez/fixOnDeviceRotation
Fix ScalingCarousel on Device Rotation
2018-05-28 10:34:08 +04:00
pabsanmez cf744094b0 Added feature to example 2018-05-27 21:35:02 +02:00
pabsanmez 8f7b1d1b1d Fix Device Rotated and autolayout mainView in code version 2018-05-27 21:20:35 +02:00
Pete Smith 550c7aa195 Merge pull request #35 from superpeteblaze/psmith/v2.2
Psmith/v2.2
2018-04-01 18:13:26 +01:00
Pete Smith 69b1cc6d22 Bump version, podspec 2018-04-01 18:09:42 +01:00
Pete Smith eebd1356e9 Expose scale, alpha related values, allow overriding 2018-04-01 18:08:29 +01:00
Pete Smith 04bf9a7c7a Use flow delegate in example 2018-03-31 19:18:04 +01:00
Pete Smith b7f4bb87d4 Update README.md 2018-03-31 17:47:46 +01:00
Pete Smith 787ec87abf Issue 31: Too many animations are taking place at one time 2018-03-31 17:30:43 +01:00
Pete Smith 2e94769bd3 Update README.md 2018-02-11 15:21:42 +00:00
16 changed files with 217 additions and 92 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+13 -1
View File
@@ -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;
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@@ -37,7 +36,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.1</string>
<string>2.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
@@ -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 = "<group>"; };
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
65678AFD206FEAF900A0ED42 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
659A02AC202F775500587C36 /* ScalingCarousel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ScalingCarousel.h; sourceTree = "<group>"; };
659A02AD202F775500587C36 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
65E99FA01E1519D50026BEC4 /* CodeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodeViewController.swift; sourceTree = "<group>"; };
@@ -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)",
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -40,7 +40,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -70,11 +69,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
disableMainThreadChecker = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
stopOnEveryThreadSanitizerIssue = "YES"
stopOnEveryMainThreadCheckerIssue = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
+2 -27
View File
@@ -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:.
}
}
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.19" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="jed-5q-J52">
<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>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.16"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
@@ -13,10 +14,6 @@
<scene sceneID="ufC-wZ-h7g">
<objects>
<viewController id="vXZ-lx-hvc" customClass="StoryboardViewController" customModule="ScalingCarousel_Example" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jyV-Pf-zRb"/>
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -86,12 +83,13 @@
<constraints>
<constraint firstItem="Mq8-SH-Mx8" firstAttribute="width" secondItem="kh9-bI-dsS" secondAttribute="width" id="4Ux-ib-2uZ"/>
<constraint firstItem="UYO-rO-XuZ" firstAttribute="centerX" secondItem="KAz-De-GJ8" secondAttribute="centerX" id="8U2-jX-Aw6"/>
<constraint firstItem="KAz-De-GJ8" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" constant="85" id="Ffh-uk-Qnl"/>
<constraint firstItem="2fi-mo-0CV" firstAttribute="top" secondItem="Mq8-SH-Mx8" secondAttribute="bottom" constant="15" id="Kee-s5-jSC"/>
<constraint firstItem="KAz-De-GJ8" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="M5E-lE-5Pp"/>
<constraint firstItem="Mq8-SH-Mx8" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leading" id="NPp-qY-rgM"/>
<constraint firstItem="KAz-De-GJ8" firstAttribute="top" secondItem="6xk-R0-sgg" secondAttribute="top" constant="85" id="Ffh-uk-Qnl"/>
<constraint firstItem="6xk-R0-sgg" firstAttribute="bottom" secondItem="Mq8-SH-Mx8" secondAttribute="bottom" constant="15" id="Kee-s5-jSC"/>
<constraint firstItem="KAz-De-GJ8" firstAttribute="centerX" secondItem="6xk-R0-sgg" secondAttribute="centerX" id="M5E-lE-5Pp"/>
<constraint firstItem="Mq8-SH-Mx8" firstAttribute="leading" secondItem="6xk-R0-sgg" secondAttribute="leading" id="NPp-qY-rgM"/>
<constraint firstItem="UYO-rO-XuZ" firstAttribute="top" secondItem="KAz-De-GJ8" secondAttribute="bottom" constant="8" id="nfn-SZ-h6K"/>
</constraints>
<viewLayoutGuide key="safeArea" id="6xk-R0-sgg"/>
</view>
<tabBarItem key="tabBarItem" title="Storyboard" id="7Ol-Hv-b1V"/>
<connections>
@@ -102,45 +100,41 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-332" y="-851"/>
<point key="canvasLocation" x="-1122" y="-1047"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="eqA-eL-972">
<objects>
<tabBarController id="BY5-bO-M1j" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="9bU-a6-6gx">
<rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="viewControllers" id="V6k-Nc-Rnj"/>
<segue destination="GQ1-V2-c06" kind="relationship" relationship="viewControllers" id="4Qb-nt-Ms8"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="5u5-Rc-3uB" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-2116" y="-646"/>
</scene>
<!--Code-->
<scene sceneID="xPD-nt-BgT">
<objects>
<viewController id="GQ1-V2-c06" customClass="CodeViewController" customModule="ScalingCarousel_Example" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="5AE-Qq-kPx"/>
<viewControllerLayoutGuide type="bottom" id="9A3-dh-CXO"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="eKu-Eq-cui">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<viewLayoutGuide key="safeArea" id="vm8-mu-b8r"/>
</view>
<tabBarItem key="tabBarItem" title="Code" id="kLX-so-YYg"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Cgm-DY-ogT" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-332" y="-40"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="t1i-tV-bQ3">
<objects>
<tabBarController automaticallyAdjustsScrollViewInsets="NO" id="jed-5q-J52" sceneMemberID="viewController">
<toolbarItems/>
<tabBar key="tabBar" contentMode="scaleToFill" id="Xg8-GK-uv2">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tabBar>
<connections>
<segue destination="vXZ-lx-hvc" kind="relationship" relationship="viewControllers" id="eFb-K1-qYg"/>
<segue destination="GQ1-V2-c06" kind="relationship" relationship="viewControllers" id="fz0-ik-wQS"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iNH-e4-Uuq" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-1431" y="-467"/>
<point key="canvasLocation" x="-1122" y="-309"/>
</scene>
</scenes>
</document>
@@ -16,6 +16,13 @@ class CodeCell: ScalingCarouselCell {
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)
])
}
required init?(coder aDecoder: NSCoder) {
@@ -40,6 +47,13 @@ class CodeViewController: UIViewController {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
if scalingCarousel != nil {
scalingCarousel.deviceRotated()
}
}
// MARK: - Configuration
@@ -76,7 +90,11 @@ extension CodeViewController: UICollectionViewDataSource {
if let scalingCell = cell as? ScalingCarouselCell {
scalingCell.mainView.backgroundColor = .blue
}
DispatchQueue.main.async {
cell.setNeedsLayout()
cell.layoutIfNeeded()
}
return cell
}
}
@@ -84,6 +102,6 @@ extension CodeViewController: UICollectionViewDataSource {
extension CodeViewController: UICollectionViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
scalingCarousel.didScroll()
//scalingCarousel.didScroll()
}
}
+9 -1
View File
@@ -15,10 +15,18 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>2.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
@@ -30,7 +30,11 @@ class StoryboardViewController: UIViewController {
carouselBottomConstraint.constant = Constants.carouselHideConstant
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
carousel.deviceRotated()
}
// MARK: - Button Actions
@IBAction func showHideButtonPressed(_ sender: Any) {
@@ -56,6 +60,11 @@ extension CarouselDatasource: UICollectionViewDataSource {
if let scalingCell = cell as? ScalingCarouselCell {
scalingCell.mainView.backgroundColor = .red
}
DispatchQueue.main.async {
cell.setNeedsLayout()
cell.layoutIfNeeded()
}
return cell
}
@@ -65,10 +74,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
}
}
+45 -2
View File
@@ -32,6 +32,19 @@ ScalingCarousel can be added via both storyboard/xib and code, as described belo
* 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;
@@ -43,6 +56,13 @@ override init(frame: CGRect) {
// 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)
])
}
```
@@ -70,6 +90,22 @@ scalingCarousel.topAnchor.constraint(equalTo: view.topAnchor, constant: 50).isAc
* 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.
@@ -80,13 +116,20 @@ iOS 9
## Installation
ScalingCarousel is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
ScalingCarousel is available through [CocoaPods](http://cocoapods.org) and [Carthage](https://github.com/Carthage/Carthage).
To install via Cocoapods, add the following line to your Podfile:
```ruby
pod "ScalingCarousel"
```
To install via Carthage, add the following line to your Podfile:
```
github "superpeteblaze/ScalingCarousel"
```
## Author
Pete Smith, peadar81@gmail.com
+1 -1
View File
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'ScalingCarousel'
s.version = '2.1'
s.version = '2.3'
s.summary = 'A super simple carousel view with scaling transitions written in Swift'
s.description = <<-DESC
@@ -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
@@ -16,7 +16,11 @@ import UIKit
are scaled as the carousel scrolls.
*/
open class ScalingCarouselView: UICollectionView {
// MARK: - Properties (Private)
private var lastCurrentCenterCellIndex: IndexPath?
// MARK: - Properties (Public)
/// Inset of the main, center cell
@@ -118,6 +122,7 @@ open class ScalingCarouselView: UICollectionView {
let originX = (CGFloat(indexPath.item) * (frame.size.width - (inset * 2)))
let rect = CGRect(x: originX, y: 0, width: frame.size.width - (inset * 2), height: frame.height)
scrollRectToVisible(rect, animated: animated)
lastCurrentCenterCellIndex = indexPath
}
override open func didMoveToSuperview() {
@@ -141,6 +146,26 @@ open class ScalingCarouselView: UICollectionView {
public func didScroll() {
scrollViewDidScroll(self)
}
/*
This method should ALWAYS be called from the ViewController that handles the ScalingCarousel when
the viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) method is called
e.g Implement:
func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
carousel.deviceRotated()
}
*/
public func deviceRotated() {
guard let lastCurrentCenterCellIndex = currentCenterCellIndex ?? lastCurrentCenterCellIndex else { return }
DispatchQueue.main.async {
self.reloadData()
self.scrollToItem(at: lastCurrentCenterCellIndex, at: .centeredHorizontally, animated: false)
self.didScroll()
}
}
}
private typealias PrivateAPI = ScalingCarouselView
@@ -245,6 +270,8 @@ extension InvisibleScrollDelegate: UIScrollViewDelegate {
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
delegate?.scrollViewDidEndDecelerating?(scrollView)
guard let indexPath = currentCenterCellIndex else { return }
lastCurrentCenterCellIndex = indexPath
}
private func updateOffSet() {