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; 
}