MyRewardsBannerOffersScrollTableViewCell collectionView fixes
Showing
5 changed files
with
53 additions
and
14 deletions
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> | 7 | <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
| ... | @@ -36,6 +36,35 @@ import UIKit | ... | @@ -36,6 +36,35 @@ import UIKit |
| 36 | 36 | ||
| 37 | // Register XIBs for collection view cells | 37 | // Register XIBs for collection view cells |
| 38 | collectionView.register(UINib(nibName: "MyRewardsBannerOfferCollectionViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellWithReuseIdentifier: "MyRewardsBannerOfferCollectionViewCell") | 38 | collectionView.register(UINib(nibName: "MyRewardsBannerOfferCollectionViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellWithReuseIdentifier: "MyRewardsBannerOfferCollectionViewCell") |
| 39 | + | ||
| 40 | + // Fix background colors | ||
| 41 | + collectionView.backgroundColor = UIColor.clear | ||
| 42 | + self.backgroundColor = UIColor.clear | ||
| 43 | + self.contentView.backgroundColor = UIColor.clear | ||
| 44 | + | ||
| 45 | + // Remove content insets and gaps | ||
| 46 | + collectionView.contentInset = UIEdgeInsets.zero | ||
| 47 | + collectionView.scrollIndicatorInsets = UIEdgeInsets.zero | ||
| 48 | + | ||
| 49 | + if #available(iOS 11.0, *) { | ||
| 50 | + collectionView.contentInsetAdjustmentBehavior = .never | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + // Configure collection view layout | ||
| 54 | + if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout { | ||
| 55 | + layout.scrollDirection = .horizontal | ||
| 56 | + layout.minimumLineSpacing = 0 | ||
| 57 | + layout.minimumInteritemSpacing = 0 | ||
| 58 | + layout.sectionInset = UIEdgeInsets.zero | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + // Enable paging for smooth banner scrolling | ||
| 62 | + collectionView.isPagingEnabled = true | ||
| 63 | + collectionView.showsHorizontalScrollIndicator = false | ||
| 64 | + | ||
| 65 | + // Set delegates | ||
| 66 | + collectionView.delegate = self | ||
| 67 | + collectionView.dataSource = self | ||
| 39 | } | 68 | } |
| 40 | 69 | ||
| 41 | public override func setSelected(_ selected: Bool, animated: Bool) { | 70 | public override func setSelected(_ selected: Bool, animated: Bool) { |
| ... | @@ -50,7 +79,8 @@ import UIKit | ... | @@ -50,7 +79,8 @@ import UIKit |
| 50 | } | 79 | } |
| 51 | } | 80 | } |
| 52 | 81 | ||
| 53 | -extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,UICollectionViewDelegate { | 82 | +extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { |
| 83 | + | ||
| 54 | 84 | ||
| 55 | public func numberOfSections(in collectionView: UICollectionView) -> Int { | 85 | public func numberOfSections(in collectionView: UICollectionView) -> Int { |
| 56 | return 1 | 86 | return 1 |
| ... | @@ -72,15 +102,24 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,U | ... | @@ -72,15 +102,24 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,U |
| 72 | public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | 102 | public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| 73 | // TODO: open offer | 103 | // TODO: open offer |
| 74 | } | 104 | } |
| 105 | + | ||
| 106 | + // MARK: - UICollectionViewDelegateFlowLayout | ||
| 107 | + public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | ||
| 108 | + let screenWidth = UIScreen.main.bounds.width | ||
| 109 | + return CGSize(width: screenWidth, height: 348) | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + // Distance Between Item Cells | ||
| 113 | + public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { | ||
| 114 | + return 0 | ||
| 115 | + } | ||
| 75 | 116 | ||
| 76 | -// // Distance Between Item Cells | 117 | + public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { |
| 77 | -// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { | 118 | + return 0 |
| 78 | -// return 5 | 119 | + } |
| 79 | -// } | 120 | + |
| 80 | -// | 121 | + // Cell Margin |
| 81 | -// // Cell Margin | 122 | + public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { |
| 82 | -// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { | 123 | + return UIEdgeInsets.zero |
| 83 | -// return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0) | 124 | + } |
| 84 | -// } | ||
| 85 | - | ||
| 86 | } | 125 | } | ... | ... |
| ... | @@ -120,7 +120,7 @@ | ... | @@ -120,7 +120,7 @@ |
| 120 | <constraint firstAttribute="trailing" secondItem="JTs-J5-DO2" secondAttribute="trailing" constant="24" id="Rdi-FK-2Ft"/> | 120 | <constraint firstAttribute="trailing" secondItem="JTs-J5-DO2" secondAttribute="trailing" constant="24" id="Rdi-FK-2Ft"/> |
| 121 | <constraint firstAttribute="trailing" secondItem="I7z-Fz-SNP" secondAttribute="trailing" id="avB-Gc-ttI"/> | 121 | <constraint firstAttribute="trailing" secondItem="I7z-Fz-SNP" secondAttribute="trailing" id="avB-Gc-ttI"/> |
| 122 | <constraint firstItem="I7z-Fz-SNP" firstAttribute="leading" secondItem="VzF-dQ-3Wa" secondAttribute="leading" id="pTY-7d-s1S"/> | 122 | <constraint firstItem="I7z-Fz-SNP" firstAttribute="leading" secondItem="VzF-dQ-3Wa" secondAttribute="leading" id="pTY-7d-s1S"/> |
| 123 | - <constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="JTs-J5-DO2" secondAttribute="bottom" constant="20" id="vJF-jy-p83"/> | 123 | + <constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="JTs-J5-DO2" secondAttribute="bottom" constant="10" id="vJF-jy-p83"/> |
| 124 | </constraints> | 124 | </constraints> |
| 125 | </view> | 125 | </view> |
| 126 | </subviews> | 126 | </subviews> | ... | ... |
-
Please register or login to post a comment