From 43f76b4bd1768deabe1880c1d166ee205a1af875 Mon Sep 17 00:00:00 2001
From: "jiaxiang.tan" <3464177517@qq.com>
Date: Mon, 21 Sep 2020 17:42:12 +0800
Subject: [PATCH] Fixed cell offset bug: when XIB loaded JXBanner with
Pagecount equal to 1
JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
---
Example/JXBanner.xcodeproj/project.pbxproj | 4 ++--
Example/JXBanner/Info.plist | 11 +++++-----
Example/Pods/Pods.xcodeproj/project.pbxproj | 22 +++++++++----------
JXBanner.podspec | 2 +-
.../Banner/Banner/JXBannerLayout.swift | 15 ++++++++++---
5 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/Example/JXBanner.xcodeproj/project.pbxproj b/Example/JXBanner.xcodeproj/project.pbxproj
index c39897f..52f8a63 100644
--- a/Example/JXBanner.xcodeproj/project.pbxproj
+++ b/Example/JXBanner.xcodeproj/project.pbxproj
@@ -632,7 +632,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -652,7 +652,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 5.0;
};
name = Release;
};
diff --git a/Example/JXBanner/Info.plist b/Example/JXBanner/Info.plist
index b086f75..5b0d797 100644
--- a/Example/JXBanner/Info.plist
+++ b/Example/JXBanner/Info.plist
@@ -2,11 +2,6 @@
- NSAppTransportSecurity
-
- NSAllowsArbitraryLoads
-
-
CFBundleDevelopmentRegion
en
CFBundleDisplayName
@@ -29,6 +24,11 @@
1
LSRequiresIPhoneOS
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
@@ -41,6 +41,7 @@
UIInterfaceOrientationPortrait
UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
diff --git a/Example/Pods/Pods.xcodeproj/project.pbxproj b/Example/Pods/Pods.xcodeproj/project.pbxproj
index 699292a..214fc09 100644
--- a/Example/Pods/Pods.xcodeproj/project.pbxproj
+++ b/Example/Pods/Pods.xcodeproj/project.pbxproj
@@ -121,7 +121,7 @@
/* Begin PBXFileReference section */
0287752C5A6BFAD69522F171FE67C69D /* ConstraintMakerPriortizable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerPriortizable.swift; path = Source/ConstraintMakerPriortizable.swift; sourceTree = ""; };
02BB2DC76B097EEC8C0772D7AB32BA6F /* JXBannerPageControlBuilder.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBannerPageControlBuilder.swift; path = JXBanner/Classes/PageControl/JXBannerPageControlBuilder.swift; sourceTree = ""; };
- 0909C73C5F9793C5958F609BFD074259 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = SnapKit.framework; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 0909C73C5F9793C5958F609BFD074259 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
0B9D0BD258AB49A6465CD2F7F6F6A5E4 /* JXPageControlLine.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXPageControlLine.swift; path = JXPageControl/Classes/Jump/JXPageControlLine.swift; sourceTree = ""; };
0BC698E1DCA9EEEAE00B79B729098422 /* JXBannerTransformLinear.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBannerTransformLinear.swift; path = JXBanner/Classes/Banner/Transform/JXBannerTransformLinear.swift; sourceTree = ""; };
0C490943A9F54848FC49E77B7B9869DA /* ConstraintConfig.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintConfig.swift; path = Source/ConstraintConfig.swift; sourceTree = ""; };
@@ -153,7 +153,7 @@
52654F3308568CF99DFECF17A113D193 /* SnapKit-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SnapKit-umbrella.h"; sourceTree = ""; };
5557ED81910BC64D4E89FBA0D6D61E71 /* JXBanner-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "JXBanner-umbrella.h"; sourceTree = ""; };
6A02F8C9AFD23635DE32A38173ACC215 /* JXBannerDelegate.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBannerDelegate.swift; path = JXBanner/Classes/Banner/API/JXBannerDelegate.swift; sourceTree = ""; };
- 6CA792D354251AD1668350A8B4A9CEF5 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE; sourceTree = ""; };
+ 6CA792D354251AD1668350A8B4A9CEF5 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = ""; };
6D0E5A0D7E8D4117E685BD79621CA583 /* LayoutConstraint.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = LayoutConstraint.swift; path = Source/LayoutConstraint.swift; sourceTree = ""; };
6E354CCC94B948026081A7FE62AE3002 /* ConstraintPriority.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintPriority.swift; path = Source/ConstraintPriority.swift; sourceTree = ""; };
6E524F6DBDE960D9CA58C84A973B16CA /* SnapKit-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SnapKit-prefix.pch"; sourceTree = ""; };
@@ -161,21 +161,21 @@
741B22239EB57D90C2042071E62595F7 /* ConstraintConstantTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintConstantTarget.swift; path = Source/ConstraintConstantTarget.swift; sourceTree = ""; };
74E4F29F1D68ADBDCA283B0D4CBD6152 /* JXBanner-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "JXBanner-Info.plist"; sourceTree = ""; };
74F1BF5F371AD7962B918696C2186186 /* JXBanner-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "JXBanner-dummy.m"; sourceTree = ""; };
- 7BD90135AFFC300C79BED5A8E446E5D0 /* Pods_JXBanner_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = Pods_JXBanner_Example.framework; path = "Pods-JXBanner_Example.framework"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 7BD90135AFFC300C79BED5A8E446E5D0 /* Pods_JXBanner_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JXBanner_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7DE4A20C66B8739C0B173987392A7608 /* JXPageControl-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "JXPageControl-Info.plist"; sourceTree = ""; };
7EBD668FE304474E75C643B1F41C2918 /* ConstraintLayoutSupport.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutSupport.swift; path = Source/ConstraintLayoutSupport.swift; sourceTree = ""; };
7F78D3307348642F2B3E10E26F6E6F54 /* ConstraintItem.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintItem.swift; path = Source/ConstraintItem.swift; sourceTree = ""; };
82642C69FAC8150A1598DA763667F6F7 /* JXBannerTransformCoverflow.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBannerTransformCoverflow.swift; path = JXBanner/Classes/Banner/Transform/JXBannerTransformCoverflow.swift; sourceTree = ""; };
- 82785579B4BB73691B4571A788CA5B83 /* JXBanner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = JXBanner.framework; path = JXBanner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ 82785579B4BB73691B4571A788CA5B83 /* JXBanner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JXBanner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
842193070C12A72ECB4F1CDEE1A27038 /* Pods-JXBanner_Example-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-JXBanner_Example-Info.plist"; sourceTree = ""; };
846F4E45A51AB41AD1FBD541911C21DA /* ConstraintOffsetTarget.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintOffsetTarget.swift; path = Source/ConstraintOffsetTarget.swift; sourceTree = ""; };
86243779885A89BFD40AA25D537E2ACD /* ConstraintLayoutSupportDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutSupportDSL.swift; path = Source/ConstraintLayoutSupportDSL.swift; sourceTree = ""; };
8E7210D6DD1F2688E4E3F9556F7F12AA /* JXPageControl-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "JXPageControl-dummy.m"; sourceTree = ""; };
- 8F1F138E4A36760593CD2F1F8C8A4907 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; path = README.md; sourceTree = ""; };
+ 8F1F138E4A36760593CD2F1F8C8A4907 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; };
94E95A72538D27EDE6CD5FCD0FD925BA /* JXPageControlJump.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXPageControlJump.swift; path = JXPageControl/Classes/Jump/JXPageControlJump.swift; sourceTree = ""; };
98F0DE1DD9F743281DBFA82BA8CE37EB /* JXPageControl.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = JXPageControl.xcconfig; sourceTree = ""; };
999EDE29E6EDB2FE1131095FE212EDFE /* JXPageControlTool.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXPageControlTool.swift; path = JXPageControl/Classes/Common/JXPageControlTool.swift; sourceTree = ""; };
- 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
+ 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
9E210C8FB3212B61963E6C0056714960 /* JXBannerCell.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBannerCell.swift; path = JXBanner/Classes/Banner/Cell/JXBannerCell.swift; sourceTree = ""; };
A11FB038514379D3755EC971672CD3E0 /* Pods-JXBanner_Example-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-JXBanner_Example-frameworks.sh"; sourceTree = ""; };
A163B7B09ACB7927E5FE0E5F0DAD9171 /* JXPageControlFill.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXPageControlFill.swift; path = JXPageControl/Classes/Transform/JXPageControlFill.swift; sourceTree = ""; };
@@ -195,7 +195,7 @@
BBF6DE944C4BA6D7A11BCF201B5A58E9 /* JXBannerType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBannerType.swift; path = JXBanner/Classes/Banner/API/JXBannerType.swift; sourceTree = ""; };
BC761311EA28A0E21DCBE1585C33694D /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintLayoutGuideDSL.swift; path = Source/ConstraintLayoutGuideDSL.swift; sourceTree = ""; };
BDAC684DC191CA97C56A9AB92B642C24 /* JXBanner-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "JXBanner-prefix.pch"; sourceTree = ""; };
- BFB9FE8041222FC1C934B8B9C2C27FD0 /* JXBanner.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = JXBanner.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
+ BFB9FE8041222FC1C934B8B9C2C27FD0 /* JXBanner.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; path = JXBanner.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
C4D74113E52DCB4F7A1AAD717946B41E /* JXBaseBanner.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBaseBanner.swift; path = JXBanner/Classes/Banner/Banner/JXBaseBanner.swift; sourceTree = ""; };
C6DF5B4FB133A3148E670FE7B5D4850B /* JXPageControlBase.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXPageControlBase.swift; path = JXPageControl/Classes/Common/JXPageControlBase.swift; sourceTree = ""; };
C80EA48F1E6E30C692EBBEC76F3AC0C8 /* ConstraintDSL.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintDSL.swift; path = Source/ConstraintDSL.swift; sourceTree = ""; };
@@ -212,7 +212,7 @@
E0B87C7D080FC051E35676D2594816DF /* JXPageControlScale.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXPageControlScale.swift; path = JXPageControl/Classes/Transform/JXPageControlScale.swift; sourceTree = ""; };
E4D9C02D201B60CE41146DEC090F7172 /* Pods-JXBanner_Example.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = "Pods-JXBanner_Example.modulemap"; sourceTree = ""; };
E8F99B3D2CB0B9A24388B4229F464DF3 /* JXBanner.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = JXBanner.modulemap; sourceTree = ""; };
- EEBDCB8705FF08A6696F40EDE2B29852 /* JXPageControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = JXPageControl.framework; path = JXPageControl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ EEBDCB8705FF08A6696F40EDE2B29852 /* JXPageControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JXPageControl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EED9B9EB52BFF37F00F252082BA0BE02 /* JXBanner.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = JXBanner.swift; path = JXBanner/Classes/Banner/Banner/JXBanner.swift; sourceTree = ""; };
F0BC1BAB8FE642334D5ABD1D0C68CADC /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ConstraintMakerRelatable.swift; path = Source/ConstraintMakerRelatable.swift; sourceTree = ""; };
F4431CB2674E24E47A4FA4CB2C46CA48 /* Debugging.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Debugging.swift; path = Source/Debugging.swift; sourceTree = ""; };
@@ -427,7 +427,6 @@
F9068C0B086B34802C24E518D96E6FC4 /* Support Files */,
E58ED26DC90023BE62A3CE8BF4FE519E /* Transform */,
);
- name = JXPageControl;
path = JXPageControl;
sourceTree = "";
};
@@ -528,7 +527,6 @@
309B90D1E114BD5D8BFBA680054E6004 /* UILayoutSupport+Extensions.swift */,
850AF63BF7A4FDBFE2822918BEF58EA0 /* Support Files */,
);
- name = SnapKit;
path = SnapKit;
sourceTree = "";
};
@@ -695,6 +693,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
+ English,
en,
);
mainGroup = CF1408CF629C7361332E53B88F7BD30C;
@@ -922,8 +921,7 @@
MTL_FAST_MATH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
STRIP_INSTALLED_PRODUCT = NO;
- SWIFT_COMPILATION_MODE = wholemodule;
- SWIFT_OPTIMIZATION_LEVEL = "-O";
+ SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SYMROOT = "${SRCROOT}/../build";
};
diff --git a/JXBanner.podspec b/JXBanner.podspec
index 3e42b6c..8d188cf 100644
--- a/JXBanner.podspec
+++ b/JXBanner.podspec
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = 'JXBanner'
- s.version = '0.3.1'
+ s.version = '0.3.2'
s.summary = 'A multifunctional framework for banner unlimited rollover diagrams'
# This description is used to generate tags and improve search results.
diff --git a/JXBanner/Classes/Banner/Banner/JXBannerLayout.swift b/JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
index f1d3e9e..e5ed6d8 100644
--- a/JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
+++ b/JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
@@ -21,19 +21,28 @@ class JXBannerLayout: UICollectionViewFlowLayout {
var params: JXBannerLayoutParams? {
didSet {
if let params = params {
+ shouldInvalidateLayout = true
itemSize = params.itemSize ?? collectionView?.bounds.size ?? CGSize(width: 2, height: 2)
minimumLineSpacing = params.itemSpacing
minimumInteritemSpacing = params.itemSpacing
}
}
}
-
+
+ /// Fixed cell offset bug: when XIB loaded JXBanner with Pagecount equal to 1
+ var shouldInvalidateLayout = true
+
var isPagingEnabled: Bool = true
override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) ->
Bool {
- if let _ = params?.layoutType { return true }
- return super.shouldInvalidateLayout(forBoundsChange: newBounds)
+
+ if shouldInvalidateLayout || params?.layoutType != nil {
+ shouldInvalidateLayout = false
+ return true
+ }
+
+ return super.shouldInvalidateLayout(forBoundsChange: newBounds)
}
override func prepare() {