2014-01-21 32 views

回答

0

你描述的聲音聽起來像是在UICollectionView中的layoutTransition。我的建議是通過繼承UICollectionViewLayout創建一個新的佈局,並覆蓋

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath

在那裏,你可以修改你的項目的框架來創建你正在尋找的效果。特別是,您可以跟蹤選定的indexPath並保持該項目不受影響。其餘的你可以這樣做:

CGRect selectedItemFrame = [[super layoutAttributesForItemAtIndexPath:self.selectedIndexPath] frame]; 

CGFloat xOffset = attributes.frame.origin.x <= selectedItemFrame.origin.x ? -400.0 : 400.0; 
CGFloat yOffset = attributes.frame.origin.y <= selectedItemFrame.origin.y ? -600.0 : 600.0; 
CGRect newFrame = CGRectOffset(attributes.frame, xOffset, yOffset); 
attributes.frame = newFrame; 

然後,只需觸發從一個佈局到另一個佈局的過渡。

相關問題