UICollectionViewFlowLayout(布局条件)
NS_CLASS_AVAILABLE_IOS(6_0) @interface UICollectionViewFlowLayout : UICollectionViewLayout
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
//单元格大小
@property (nonatomic) CGSize itemSize;
//设置最小水平间隙
collectionView.minimumZoomScale = 10;
//设置竖直间隙
collectionView.maximumZoomScale = 20;
//设置四周大小
flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
//滑动方向
@property (nonatomic) UICollectionViewScrollDirection scrollDirection;
UICollectionViewScrollDirectionVertical, //竖直
UICollectionViewScrollDirectionHorizontal //水平
@protocol UICollectionViewDelegateFlowLayout
@optional
//设置单元格大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
UICollectionView
@interface UICollectionView : UIScrollView
//创建带布局条件的单元格视图
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout
//通过类名注册单元格类
- (void)registerClass:(nullable Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier;
//通过xib注册单元格类
- (void)registerNib:(nullable UINib *)nib forCellWithReuseIdentifier:(NSString *)identifier;
//滑动到indexPath单元格
- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated;
@protocol UICollectionViewDataSource
@required
//单元格个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section;
//单元格类型
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
@protocol UICollectionViewDelegate
@optional
//选中单元格执行
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
//单元格结束显示调用
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath;
@interface UIScrollView : UIView
- (void)setZoomScale:(CGFloat)scale animated:(BOOL)animated NS_AVAILABLE_IOS(3_0);
@protocol UIScrollViewDelegate
//返回哪个视图哪个视图进行缩放
//1 调用上面方法通过设置缩放倍数
//2 或者通过滑动设置
- (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
@interface UIView(UIViewHierarchy)
//一般内容视图调用(UIScrollView *)scrollView.contentView
//根据下标交换子视图位置
- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;