草庐IT

UICollectionViewLayoutAttributes

全部标签

ios - UICollection View 流布局垂直对齐

默认情况下,当您在CollectionView中使用流布局时,单元格垂直居中。有没有办法改变这种对齐方式? 最佳答案 采用面向功能的方法的Swift4:classTopAlignedCollectionViewFlowLayout:UICollectionViewFlowLayout{overridefunclayoutAttributesForElements(inrect:CGRect)->[UICollectionViewLayoutAttributes]?{letattributes=super.layoutAttribut

ios - UICollection View 流布局垂直对齐

默认情况下,当您在CollectionView中使用流布局时,单元格垂直居中。有没有办法改变这种对齐方式? 最佳答案 采用面向功能的方法的Swift4:classTopAlignedCollectionViewFlowLayout:UICollectionViewFlowLayout{overridefunclayoutAttributesForElements(inrect:CGRect)->[UICollectionViewLayoutAttributes]?{letattributes=super.layoutAttribut

swift - NSInternalInconsistencyException',原因 : 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForItemAtIndexPath, 自定义布局

我有一个带有自定义UICollectionLayout的UICollectionView。一切正常,直到我尝试插入一行……然后我收到以下错误,似乎无法弄清楚如何解决它。***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'noUICollectionViewLayoutAttributesinstancefor-layoutAttributesForItemAtIndexPath:{length=2,path=0-0}'***Firstthrowcallstack:(0Core

swift - NSInternalInconsistencyException',原因 : 'no UICollectionViewLayoutAttributes instance for -layoutAttributesForItemAtIndexPath, 自定义布局

我有一个带有自定义UICollectionLayout的UICollectionView。一切正常,直到我尝试插入一行……然后我收到以下错误,似乎无法弄清楚如何解决它。***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'noUICollectionViewLayoutAttributesinstancefor-layoutAttributesForItemAtIndexPath:{length=2,path=0-0}'***Firstthrowcallstack:(0Core

ios - 在 UICollectionViewLayoutAttributes 中设置 anchor

我想在UICollectionViewLayout中执行转换动画。好吧,这很容易实现,但我找不到设置UICollectionViewLayoutAttributes的anchorPoint的方法。我想在插入CollectionView项时执行开门和关门动画-(UICollectionViewLayoutAttributes*)initialLayoutAttributesForAppearingItemAtIndexPath:(NSIndexPath*)itemIndexPath{UICollectionViewLayoutAttributes*attributes=[superini

ios - 动画 UICollectionViewFlowLayout 子类 UICollectionViewLayoutAttributes 框架变化

我对UICollectionViewFlowLayout进行了子分类,在该子类中,我正在更改UICollectionViewLayoutAttributes框架,以便它们看起来更大或更小-取决于它们的位置在屏幕上。我正在layoutAttributesForElementsInRect中执行框架更改:并在layoutAttributesForItemAtIndexPath中返回它:我在shouldInvalidateLayoutForBoundsChange中返回YES:一切正常,但单元格不会为帧的变化设置动画。我错过了什么吗?为什么更改没有动画化?谢谢。

ios - 使用自定义 UICollectionViewLayout 时出现“-layoutAttributesForItemAtIndexPath 没有 UICollectionViewLayoutAttributes 实例”错误

我正在使用像这样的自定义UICollectionViewLayout:overridefuncprepareLayout(){cache.removeAll(keepCapacity:false)letstandardHeight=LayoutConstants.Cell.standardHeightletfeaturedHeight=LayoutConstants.Cell.featuredHeightvarframe=CGRectZerovary:CGFloat=0foritemin0..[AnyObject]?{varlayoutAttributes=[UICollectionV

ios - 如何使用 UICollectionViewTransitionLayout 插入自定义 UICollectionViewLayoutAttributes 属性

我有两个自定义UICollectionViewLayout对象,它们使用自定义UICollectionViewLayoutAttributes子类。这些自定义属性添加了一个属性tintAlpha,它控制附加到每个CollectionView单元格的色调叠加View的不透明度。我现在想在这两个布局之间转换,使用UICollectionViewTransitionLayout子类。如何配置过渡布局子类以在我的自定义布局属性上插入自定义tintAlpha属性?我可以这样做:-(UICollectionViewLayoutAttributes*)layoutAttributesForItemA

ios - 如何继承 UICollectionViewLayoutAttributes

我正在尝试对UICollectionViewLayoutAttributes进行子类化,以便我可以添加一个额外的属性points(CGPoints数组)。该子类被设计为仅用作装饰View的属性,因此我需要将成员representedElementCategory设置为.Decoration。但是representedElementCategory是只读的,设置它的唯一方法是通过便利初始化程序:convenienceinit(forDecorationViewOfKinddecorationViewKind:String,withIndexPathindexPath:NSIndexPat