标签:
文/Flying_Einstein(简书作者)实现垂直方向的单列表来说,使用UITableView足以;若是需要构建横向滑动列表、gridView等直线型布局,则使用UICollectionView+UICollectionViewFlowLayout搭建最合适;更复杂的布局,则可以使用UICollectionView+自定义Layout来实现。
1
|
-
(CGSize)collectionViewContentSize; |
1
|
-
( NSArray <__kindofUICollectionViewLayoutAttributes
*> *)layoutAttributesForElementsInRect:(CGRect)rect; |
1
2
3
|
+
(instancetype)layoutAttributesForCellWithIndexPath:( NSIndexPath
*)indexPath; +
(instancetype)layoutAttributesForSupplementaryViewOfKind:( NSString
*)elementKind withIndexPath:( NSIndexPath
*)indexPath; +
(instancetype)layoutAttributesForDecorationViewOfKind:( NSString
*)decorationViewKind withIndexPath:( NSIndexPath
*)indexPath; |
1
|
-(UICollectionViewLayoutAttributes
*)layoutAttributesForItemAtIndexPath:( NSIndexPath
*)indexPath |
1
|
-
(UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:( NSString
*)kind atIndexPath:( NSIndexPath
*)indexPath; |
1
|
-
(UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:( NSString
*)decorationViewKind atIndexPath:( NSIndexPath
*)indexPath; |
1
2
|
-
( BOOL )shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds [font="] |
1
|
-
(UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:( NSIndexPath
*)itemIndexPath |
1
2
3
4
|
/返回值是追加视图插入collection
view时的布局信息。该方法使用同initialLayoutAttributesForAppearingItemAtIndexPath:[/font]- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingSupplementaryElementOfKind:( NSString
*)elementKind atIndexPath:( NSIndexPath
*)elementIndexPath //返回值是装饰视图插入collection
view时的布局信息。该方法使用同initialLayoutAttributesForAppearingItemAtIndexPath: -
(UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingDecorationElementOfKind:( NSString
*)elementKind atIndexPath:( NSIndexPath
*)elementIndexPath -
(UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:( NSIndexPath
*)itemIndexPath |
1
2
3
4
|
//....不用解释了吧
..... -
(UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingSupplementaryElementOfKind:( NSString
*)elementKind atIndexPath:( NSIndexPath
*)elementIndexPath //....不用解释了吧
..... -
(UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingDecorationElementOfKind:( NSString
*)elementKind atIndexPath:( NSIndexPath
*)elementIndexPath |
1
2
3
4
|
//当一个新的布局对象分配给collection
view时,collection view将设置该属性的值 @property ( nonatomic ,
readonly )
UICollectionView *collectionView //上面已经介绍过,不再介绍 -
collectionViewContentSize; |
1
2
|
-
(UICollectionViewLayoutAttributes *)layoutAttributesForInteractivelyMovingItemAtIndexPath:( NSIndexPath
*)indexPath withTargetPosition:(CGPoint)position [font="] |
1
2
|
-
(CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset [font="] |
1
2
|
-
(CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity [font="] |
1
2
|
-
( void )prepareForCollectionViewUpdates:( NSArray <UICollectionViewUpdateItem
*> *)updateItems [font="] |
1
2
3
|
//该方法上文已介绍 -
( void )finalizeCollectionViewUpdates -
( NSArray < NSIndexPath
*> *)indexPathsToInsertForSupplementaryViewOfKind:( NSString
*)kind |
1
2
3
4
|
-
( NSArray < NSIndexPath
*> *)indexPathsToInsertForDecorationViewOfKind:( NSString
*)kind //类比上个方法,不再过多解释; -
( NSArray < NSIndexPath
*> *)indexPathsToDeleteForSupplementaryViewOfKind:( NSString
*)kind -
( NSArray < NSIndexPath
*> *)indexPathsToDeleteForDecorationViewOfKind:( NSString
*)kind; |
1
|
-
( NSIndexPath
*)targetIndexPathForInteractivelyMovingItem:( NSIndexPath
*)previousIndexPath withPosition:(CGPoint)position |
1
2
|
-
( void )invalidateLayoutWithContext:(UICollectionViewLayoutInvalidationContext
*)context [font="] |
1
2
|
-
( BOOL )shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds; [font="] |
1
2
|
-
(UICollectionViewLayoutInvalidationContext *)invalidationContextForBoundsChange:(CGRect)newbounds; [font="] |
1
2
|
-
( BOOL )shouldInvalidateLayoutForPreferredLayoutAttributes:(UICollectionViewLayoutAttributes
*)preferredAttributes withOriginalAttributes:(UICollectionViewLayoutAttributes *)originalAttributes [font="] |
1
2
|
-
(UICollectionViewLayoutInvalidationContext *)invalidationContextForPreferredLayoutAttributes:(UICollectionViewLayoutAttributes *)preferredAttributes withOriginalAttributes:(UICollectionViewLayoutAttributes *)originalAttributes [font="] |
标签:
原文地址:http://blog.csdn.net/kengsir/article/details/51725558