UICollectionView

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值