私はeBayのiOSアプリがその画像をどのように表示しているかを再現しようとしており、ユーザーは各画像を拡大することができます。ここで選択時にUICollectionViewセルを画面の幅に拡張する方法は?
は、それがどのように動作するかです:
eBayは、画像の一覧を表示するUICollectionView
を使用しています。ユーザーがセルを選択すると、セルは上部のいくつかのボタンで展開されます。 Xが選択されると、セルは元のサイズに折り畳まれます。
どうすればこのようなことができますか?
私は質問UICollectionView Enlarge cell on selectionとExpanding UICollectionView and its cell when tappedを見て、私自身のアイデアで実装しようとしました。
問題の1つは、私はAutoLayoutデザインを持っており、これは非常に難しいことです。私はこれを試してみた
:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
{
let cell = collectionView.cellForItem(at: indexPath)
cell?.superview?.bringSubview(toFront: cell!)
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: [], animations: ({
self.structureImageView.frame = CGRect(x: 0, y: 0, width: 375, height: 667)
collectionView.frame = self.structureImageView.bounds
cell?.frame = collectionView.bounds
self.separatorView.frame.origin.y = 667
self.structureInfoView.frame.origin.y = 667
}), completion: nil)
test = true
collectionView.reloadData()
}
var test = false
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize
{
if test == true
{
return CGSize(width: 375, height: 667)
}
return CGSize(width: cellWidth!, height: cellHeight!)
}
そして結果:どのような援助が大幅に
役立つだろう
は、ここに私のストーリーボードです!
UICollectionView Cellは拡張されませんが、別のコントローラがカスタムトランジションのモーダルとしてポップアップ表示されます。 [こちら](https://github.com/michaelhenry/MHFacebookImageViewer)が必要な場合があります – iphonic
複数の画像がある場合は、このhttps://github.com/zvonicek/ImageSlideshowを使用してください。 – Nitesh
@iphonicが述べたように、私はそれが細胞を拡張していないとも思う。これは、カスタムトランジションを備えたモーダルビューコントローラです。あなたがそのようにすれば、あなたの場合にはより簡単になります。私はそれが細胞とそれを行うことは不可能だと言っていない...しかし、それはもっと難しいだろう... – Seishin