diff --git a/VDS/Components/Carousel/Carousel.swift b/VDS/Components/Carousel/Carousel.swift index b344ad9a..dc1ef104 100644 --- a/VDS/Components/Carousel/Carousel.swift +++ b/VDS/Components/Carousel/Carousel.swift @@ -272,6 +272,7 @@ open class Carousel: View { super.updateView() updateScrollbar() updateCarousel() + collectionView.collectionViewLayout.invalidateLayout() collectionView.reloadData() } @@ -516,11 +517,10 @@ extension Carousel: UICollectionViewDelegate, UICollectionViewDataSource, UIColl public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CarouselSlotCell.identifier, for: indexPath) as? CarouselSlotCell else { return UICollectionViewCell() } - cell.contentView.subviews.forEach { $0.removeFromSuperview() } let component = views[indexPath.row] cell.update(with: component, slotAlignment: slotAlignment, surface: surface) cell.layoutIfNeeded() - component.setNeedsLayout() + //component.setNeedsLayout() if hasDebugBorder { cell.addDebugBorder() } else { diff --git a/VDS/Components/Carousel/CarouselSlotCell.swift b/VDS/Components/Carousel/CarouselSlotCell.swift index 11807747..d47a2595 100644 --- a/VDS/Components/Carousel/CarouselSlotCell.swift +++ b/VDS/Components/Carousel/CarouselSlotCell.swift @@ -25,11 +25,6 @@ final class CarouselSlotCell: UICollectionViewCell { super.init(coder: coder) setUp() } - - //-------------------------------------------------- - // MARK: - Private Properties - //-------------------------------------------------- - private var surface: Surface = .light //-------------------------------------------------- // MARK: - Private Methods @@ -42,7 +37,7 @@ final class CarouselSlotCell: UICollectionViewCell { /// Updating UI based on data along with surface. func update(with component: UIView, slotAlignment: Carousel.CarouselSlotAlignmentModel?, surface: Surface) { - self.surface = surface + contentView.subviews.forEach { $0.removeFromSuperview() } contentView.addSubview(component) if var surfacedView = component as? Surfaceable { surfacedView.surface = surface