Skip to main content

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: A CGFloat 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: A String representing the image URL.

Methods​

  • configure(with:crossButtonAction:): Configures the cell with the provided ContentModel data and an optional crossButtonAction closure.

Action Handlers​

  • didTapCrossButton(): The selector method for the cross button's tap action. It checks if the url is set and executes the crossButtonAction 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
}