Collection View Cells

Core

Collection view cell base classes with a padded panel container, selection highlight, and skeleton animation — mirrors the table cell family but for UICollectionView.

ClassDescription
TTBaseUICollectionViewCellBase cell — padded panel, skeleton animation, selection
BaseShadowCollectionViewCellShadow card effect on the panel
SlideImageCollectionViewCellFull-width image slide (for carousels/banners)

🚀 Usage

// Register and dequeue
collectionView.register(TTBaseUICollectionViewCell.self,
                        forCellWithReuseIdentifier: TTBaseUICollectionViewCell.reuseIdentifier)

let cell = collectionView.dequeueReusableCell(
    withReuseIdentifier: TTBaseUICollectionViewCell.reuseIdentifier,
    for: indexPath
) as! TTBaseUICollectionViewCell

// Subclass with custom content
class CategoryCell: TTBaseUICollectionViewCell {
    private let iconView = TTBaseUIImageFontView(withFontIconLightSize: .star, sizeIcon: CGSize(width: 40, height: 40), colorIcon: TTView.iconColor)
    private let titleLabel = TTBaseUILabel(withType: .SUB_TITLE, text: "", align: .center)

    override func updateUI() {
        panel.addSubview(iconView)
        panel.addSubview(titleLabel)
        // ... constraints
        panel.setConerRadius(TTSize.CORNER_RADIUS)
    }

    func configure(category: Category) {
        iconView.setIconColor(category.color)
        titleLabel.setText(text: category.name)
    }
}

// Override cell defaults
override var padding: CGFloat { return 8 }
override var bgColor: UIColor { return .systemGroupedBackground }
override var cornerRadius: CGFloat { return 12 }

// Skeleton loading
cell.setSkeletonAnimation()
cell.onStartSkeletonAnimation()
// After load:
cell.onStopSkeletonAnimation()

// Slide image carousel
collectionView.register(SlideImageCollectionViewCell.self,
                        forCellWithReuseIdentifier: SlideImageCollectionViewCell.reuseIdentifier)
// Configure banner cell
let bannerCell = collectionView.dequeueReusableCell(
    withReuseIdentifier: SlideImageCollectionViewCell.reuseIdentifier,
    for: indexPath
) as! SlideImageCollectionViewCell
bannerCell.imageView.setImage(with: banners[indexPath.item].imageURL)

📖 API Reference

MemberTypeDescription
panelTTBaseUIViewContent container with bg and corner radius
isSetPanelBgColorBoolEnable/disable selection color change
bgColorUIColorNormal state background
bgSelectColorUIColorSelected state background
paddingCGFloatPanel inset from all edges
cornerRadiusCGFloatPanel corner radius
setSkeletonAnimation()MethodAdd shimmer layer to panel
onStartSkeletonAnimation()MethodShow shimmer state
onStopSkeletonAnimation()MethodRemove shimmer, restore content
Pro Tip: TTBaseUICollectionViewCell.padding is a single uniform value (unlike the 4-tuple for table cells). For asymmetric insets, override setupBaseContraints() and manually set the panel constraints to different values per edge.