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.
UI Components
imageView
: AnLMImageView
that displays the image.crossButton
: AnLMButton
that represents the cross button for removing the image.
Data Variables
crossButtonHeight
: ACGFloat
value 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
: AString
representing the image URL.
Methods
configure(with:crossButtonAction:)
: Configures the cell with the providedContentModel
data and an optionalcrossButtonAction
closure.
Action Handlers
didTapCrossButton()
: The selector method for the cross button's tap action. It checks if theurl
is set and executes thecrossButtonAction
closure 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
}