ios - 长按并拖动时放大 UICollectionViewCell
<p><p>我想在长按和拖动时缩放 Collection View ,当用户结束拖动时,单元格应该是常规大小。</p>
<p>我正在使用以下步骤创建演示,这些步骤可以正常工作,但放大无法按预期工作。
<a href="http://nshint.io/blog/2015/07/16/uicollectionviews-now-have-easy-reordering/" rel="noreferrer noopener nofollow">Collection View Example</a> </p>
<p>这是我使用的手势代码:</p>
<pre><code>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()
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 Collection View 布局子类上试试这个:</p>
<pre><code>- (UICollectionViewLayoutAttributes*) layoutAttributesForInteractivelyMovingItemAtIndexPath:(NSIndexPath *)indexPath withTargetPosition:(CGPoint)position
{
UICollectionViewLayoutAttributes *attributes = ;
attributes.zIndex = NSIntegerMax;
attributes.transform3D = CATransform3DScale(attributes.transform3D, 1.2f, 1.2f, 1.0);
return attributes;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 长按并拖动时放大 UICollectionViewCell,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/41590815/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/41590815/
</a>
</p>
页:
[1]