iOS UICollectionView 自定义section HeaderView
首先自定义一个view 继承于 UICollectionReusableView,在自定义headerview中创建自己需要的ui 如:label, button,因为UICollectionReusableView 创建的时候不走init所以,这里使用懒加载。
.h
//
// HeaderReusableView.h
// TestBaseView
//
// Created by 金英杰 on 2020/11/19.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HeaderReusableView : UICollectionReusableView
/** <#属性注释#> */
@property (nonatomic,strong) UILabel *title;
@end
NS_ASSUME_NONNULL_END
.m
//
// HeaderReusableView.m
// TestBaseView
//
// Created by 金英杰 on 2020/11/19.
//
#import "HeaderReusableView.h"
@implementation HeaderReusableView
-(UILabel *)title{
if (!_title) {
_title = [[UILabel alloc]init];
_title.frame = CGRectMake(15, 0, jSCREEN_WIDTH-30, 30);
_title.font = jFONT(14)