2015-02-03 2 views
2

저는 UICollectionView를 사용하고 있지만 TableView처럼 사용하고 있습니다. 왼쪽으로 애니메이트하고 오른쪽에서 새 셀을 움직여서 셀을 움직이게하고 싶습니다. UITableView을 사용하면 셀을 삽입/제거하는 동안 UITableViewRowAnimation.Right 애니메이션 만 가능합니다. UICollectionView으로 어떻게 이런 일을 할 수 있습니까?collectionview 내의 테이블 뷰 애니메이션?

+0

스프링 보드처럼? 여기에 몇 개의 세포가있어? 애니메이션을 원하거나 나머지 tableView 기능을 원하십니까? – CaptJak

+0

애니메이션을 원하므로 오른쪽에서 셀을 추가하고 왼쪽에서 셀을 제거하고 싶습니다. – joslinm

+0

: http://stackoverflow.com/questions/19301762/uicollectionview-horizontal-scroll-horizontal-layout – CaptJak

답변

1

불행히도 UICollectionView에는 이러한 애니메이션의 기본 구현이 없습니다. 이러한 두 가지 방법을 UICollectionViewLayout (또는 UICollectionViewFlowLayout) 서브 클래스를 생성하고 오버라이드 (override)를 구현할 수 있습니다

// This set of methods is called when the collection view undergoes an animated transition such as a batch update block or an animated bounds change. 
// For each element on screen before the invalidation, finalLayoutAttributesForDisappearingXXX will be called and an animation setup from what is on screen to those final attributes. 
// For each element on screen after the invalidation, initialLayoutAttributesForAppearingXXX will be called an an animation setup from those initial attributes to what ends up on screen. 

func initialLayoutAttributesForAppearingItemAtIndexPath(itemIndexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? 

func finalLayoutAttributesForDisappearingItemAtIndexPath(itemIndexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? 

initialLayoutAttributesForAppearingItemAtIndexPath 위치 (attributes.center 또는 .frame.origin)로, 추가되는 요소에 대한 UICollectionViewLayoutAttributes을 반환해야하는에서 그것은 테이블 안에서 그 위치로 움직일 것입니다.

UICollectionViewLayoutAttributesalpha, transform 및 애니메이션을 조정하는 데 사용할 수있는 몇 가지 매개 변수가 있습니다.

관련 문제