UICollectionViewCell(FWDynamicLayout)

@interface UICollectionViewCell (FWDynamicLayout)

/// 如果用来确定Cell所需尺寸的View是唯一的,请把此值设置为YES,可提升一定的性能
@property (nonatomic, assign) BOOL fw_maxYViewFixed NS_REFINED_FOR_SWIFT;

/// 最大Y视图的底部内边距(横向滚动时为X),可避免新创建View来撑开Cell,默认0
@property (nonatomic, assign) CGFloat fw_maxYViewPadding NS_REFINED_FOR_SWIFT;

/// 最大Y视图是否撑开布局(横向滚动时为X),需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用
@property (nonatomic, assign) BOOL fw_maxYViewExpanded NS_REFINED_FOR_SWIFT;

/// 免注册创建UICollectionViewCell,内部自动处理缓冲池
+ (instancetype)fw_cellWithCollectionView:(UICollectionView *)collectionView
                               indexPath:(NSIndexPath *)indexPath NS_REFINED_FOR_SWIFT;

/// 免注册创建UICollectionViewCell,内部自动处理缓冲池,指定reuseIdentifier
+ (instancetype)fw_cellWithCollectionView:(UICollectionView *)collectionView
                               indexPath:(NSIndexPath *)indexPath
                         reuseIdentifier:(nullable NSString *)reuseIdentifier NS_REFINED_FOR_SWIFT;

/// 根据配置自动计算view大小,子类可重写
+ (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                   configuration:(FWCollectionCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;

/// 根据配置自动计算view大小,固定宽度,子类可重写
+ (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                           width:(CGFloat)width
                   configuration:(FWCollectionCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;

/// 根据配置自动计算view大小,固定高度,子类可重写
+ (CGSize)fw_sizeWithCollectionView:(UICollectionView *)collectionView
                          height:(CGFloat)height
                   configuration:(FWCollectionCellConfigurationBlock)configuration NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 如果用来确定Cell所需尺寸的View是唯一的,请把此值设置为YES,可提升一定的性能

    Declaration

    Objective-C

    @property (nonatomic) BOOL fw_maxYViewFixed;
  • 最大Y视图的底部内边距(横向滚动时为X),可避免新创建View来撑开Cell,默认0

    Declaration

    Objective-C

    @property (nonatomic) CGFloat fw_maxYViewPadding;
  • 最大Y视图是否撑开布局(横向滚动时为X),需布局约束完整。默认NO,无需撑开布局;YES时padding不起作用

    Declaration

    Objective-C

    @property (nonatomic) BOOL fw_maxYViewExpanded;
  • 免注册创建UICollectionViewCell,内部自动处理缓冲池

    Declaration

    Objective-C

    + (nonnull instancetype)
        fw_cellWithCollectionView:(nonnull UICollectionView *)collectionView
                        indexPath:(nonnull NSIndexPath *)indexPath;
  • 免注册创建UICollectionViewCell,内部自动处理缓冲池,指定reuseIdentifier

    Declaration

    Objective-C

    + (nonnull instancetype)
        fw_cellWithCollectionView:(nonnull UICollectionView *)collectionView
                        indexPath:(nonnull NSIndexPath *)indexPath
                  reuseIdentifier:(nullable NSString *)reuseIdentifier;
  • 根据配置自动计算view大小,子类可重写

    Declaration

    Objective-C

    + (CGSize)fw_sizeWithCollectionView:(nonnull UICollectionView *)collectionView
                          configuration:(nonnull FWCollectionCellConfigurationBlock)
                                            configuration;
  • 根据配置自动计算view大小,固定宽度,子类可重写

    Declaration

    Objective-C

    + (CGSize)fw_sizeWithCollectionView:(nonnull UICollectionView *)collectionView
                                  width:(CGFloat)width
                          configuration:(nonnull FWCollectionCellConfigurationBlock)
                                            configuration;
  • 根据配置自动计算view大小,固定高度,子类可重写

    Declaration

    Objective-C

    + (CGSize)fw_sizeWithCollectionView:(nonnull UICollectionView *)collectionView
                                 height:(CGFloat)height
                          configuration:(nonnull FWCollectionCellConfigurationBlock)
                                            configuration;

UICollectionViewCell+FWUIKit

  • 获取当前所属collectionView

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly, nullable) UICollectionView *fw_collectionView;
  • 获取当前显示indexPath

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSIndexPath *fw_indexPath;