Image View
Overview
LMFeedImageCollectionCell is used to display an image with an optional cross button for removing the image. This cell is typically used to display images in a collection view or grid layout. This is used in displaying videos in Feed List, Post Detail, Post Creation and Post Edit Screens.
File Location:
LMFeedImageCollectionCell.swift
UI Components
imageView: An LMFeedImageview that displays the image.crossButton: An LMFeedButton that represents the cross button for removing the image.
Data Variables
crossButtonHeight: ACGFloatvalue that determines the height of the cross button.crossButtonAction: A closure that is executed when the cross button is tapped, passing the image URL as a parameter.url: AStringrepresenting the image URL.
Methods
configure(with:crossButtonAction:): Configures the cell with the providedContentModeldata and an optionalcrossButtonActionclosure.
Action Handlers
didTapCrossButton(): The selector method for the cross button's tap action. It checks if theurlis set and executes thecrossButtonActionclosure if it's not nil, passing the image URL as a parameter.
Customization
CustomImageCell.swift
class CustomImageCell: LMFeedImageCollectionCell {
override func setupAppearance() {
super.setupAppearance()
containerView.backgroundColor = .green
crossButton.tintColor = .white
}
}
AppDelegate.swift
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
LMUIComponents.shared.imagePreview = CustomImageCell.self
// ...
return true
}