Skip to content

Commit 34ac677

Browse files
committed
Added parent layout for collection cell.
1 parent a0a958c commit 34ac677

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Sources/NativeUIKit/Collection/NativeLargeTitleCollectionViewCell.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,21 @@ open class NativeLargeTitleCollectionViewCell: SPCollectionViewCell {
4848
addSubview(titleLabel)
4949
}
5050

51+
open override func prepareForReuse() {
52+
super.prepareForReuse()
53+
titleLabel.text = nil
54+
parentLayout = nil
55+
}
56+
5157
// MARK: - Layout
5258

59+
open weak var parentLayout: UIView?
60+
5361
open override func layoutSubviews() {
5462
super.layoutSubviews()
55-
var collectionView: UICollectionView?
56-
if let view = superview as? UICollectionView {
57-
collectionView = view
58-
}
59-
if let view = superview?.superview as? UICollectionView {
60-
collectionView = view
61-
}
62-
if let parent = collectionView {
63-
contentView.layoutMargins.left = parent.layoutMargins.left
64-
contentView.layoutMargins.right = parent.layoutMargins.right
63+
if let parentLayout = parentLayout {
64+
contentView.layoutMargins.left = parentLayout.layoutMargins.left
65+
contentView.layoutMargins.right = parentLayout.layoutMargins.right
6566
}
6667
titleLabel.layoutDynamicHeight(
6768
x: contentView.layoutMargins.left,

0 commit comments

Comments
 (0)