Skip to content

Commit

Permalink
Fixed cell offset bug: when XIB loaded JXBanner with Pagecount equal …
Browse files Browse the repository at this point in the history
…to 1

JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
  • Loading branch information
jiaxiang.tan committed Sep 21, 2020
1 parent f08b0e6 commit 43f76b4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Example/JXBanner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
11 changes: 6 additions & 5 deletions Example/JXBanner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand All @@ -29,6 +24,11 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -41,6 +41,7 @@
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
22 changes: 10 additions & 12 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion JXBanner.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 12 additions & 3 deletions JXBanner/Classes/Banner/Banner/JXBannerLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 43f76b4

Please sign in to comment.