1

長押しでドラッグしたときにコレクションビューを拡大したいときや、ユーザーがドラッグしたときにセルが通常のサイズになるはずです。拡大UICollectionViewCellを長押ししてドラッグしたとき

以下の手順を使用してデモを作成していますが、これはうまく動作しますが、期待通りに拡大していません。ここで 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() 
    } 
} 

答えて

2

は、コレクションビューのレイアウトサブクラスでこれを試してみてください:

- (UICollectionViewLayoutAttributes*) layoutAttributesForInteractivelyMovingItemAtIndexPath:(NSIndexPath *)indexPath withTargetPosition:(CGPoint)position 
{ 
    UICollectionViewLayoutAttributes *attributes = [super layoutAttributesForInteractivelyMovingItemAtIndexPath:indexPath withTargetPosition:position]; 
    attributes.zIndex = NSIntegerMax; 
    attributes.transform3D = CATransform3DScale(attributes.transform3D, 1.2f, 1.2f, 1.0); 
    return attributes; 
} 
関連する問題