我想在长按和拖动时缩放 Collection View ,当用户结束拖动时,单元格应该是常规大小。
我正在使用以下步骤创建演示,这些步骤可以正常工作,但放大无法按预期工作。
Collection View Example
这是我使用的手势代码:
func handleLongGesture(gesture: UILongPressGestureRecognizer) {
switch(gesture.state) {
case UIGestureRecognizerState.Began:
guard let selectedIndexPath = self.collectionView.indexPathForItemAtPoint(gesture.locationInView(self.collectionView)) else {
break
}
collectionView.beginInteractiveMovementForItemAtIndexPath(selectedIndexPath)
case UIGestureRecognizerState.Changed:
collectionView.updateInteractiveMovementTargetPosition(gesture.locationInView(gesture.view!))
case UIGestureRecognizerState.Ended:
collectionView.endInteractiveMovement()
default:
collectionView.cancelInteractiveMovement()
}
}
Best Answer-推荐答案 strong>
在 Collection View 布局子类上试试这个:
- (UICollectionViewLayoutAttributes*) layoutAttributesForInteractivelyMovingItemAtIndexPathNSIndexPath *)indexPath withTargetPositionCGPoint)position
{
UICollectionViewLayoutAttributes *attributes = [super layoutAttributesForInteractivelyMovingItemAtIndexPath:indexPath withTargetPosition:position];
attributes.zIndex = NSIntegerMax;
attributes.transform3D = CATransform3DScale(attributes.transform3D, 1.2f, 1.2f, 1.0);
return attributes;
}
关于ios - 长按并拖动时放大 UICollectionViewCell,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/41590815/
|