UICollectionView に多数の画像セルを表示しています。1 つのボタンで、すべてのセルを最初のセルにグループ化できるようにしたいと考えています。
これはうまく機能していますが、アニメーション トランジションを再グループ化アクションに追加しようとしても、何も起こりません。
カスタムレイアウトで使用する方法は次のとおりです。
- (NSArray*)layoutAttributesForElementsInRect:(CGRect)rect
{
NSArray* allAttributesInRect = [super layoutAttributesForElementsInRect:rect];
if([allAttributesInRect count] > 0 && _isRegroup)
{
UICollectionViewLayoutAttributes *firstAttribute = [allAttributesInRect objectAtIndex:0];
CGRect frame = firstAttribute.frame;
for(UICollectionViewLayoutAttributes *attribute in allAttributesInRect)
[UIView animateWithDuration:0.3f animations:^{attribute.frame = frame;}];
}
return allAttributesInRect;
}
- (void)regroupCells:(BOOL)isRegroup // This method is called from my collection controller when my button is pressed
{
_isRegroup = isRegroup;
[self invalidateLayout];
}
何か案が ?ありがとう !