Collection View Cells
CoreCollection view cell base classes with a padded panel container, selection highlight, and skeleton animation — mirrors the table cell family but for UICollectionView.
| Class | Description |
|---|---|
TTBaseUICollectionViewCell | Base cell — padded panel, skeleton animation, selection |
BaseShadowCollectionViewCell | Shadow card effect on the panel |
SlideImageCollectionViewCell | Full-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
| Member | Type | Description |
|---|---|---|
panel | TTBaseUIView | Content container with bg and corner radius |
isSetPanelBgColor | Bool | Enable/disable selection color change |
bgColor | UIColor | Normal state background |
bgSelectColor | UIColor | Selected state background |
padding | CGFloat | Panel inset from all edges |
cornerRadius | CGFloat | Panel corner radius |
setSkeletonAnimation() | Method | Add shimmer layer to panel |
onStartSkeletonAnimation() | Method | Show shimmer state |
onStopSkeletonAnimation() | Method | Remove 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.