点击UIcollectionviewcell时放大单元格照片并打开新的视图控制器

时间:2016-10-01 10:53:46

标签: ios iphone swift xcode swift3

我需要在视图控制器中有一个C:\WINDOWS\wget.exe -q -O nul http://yoursite/somepage.php ,当我点击UICollectionView时,放大单元格照片,然后打开新的视图控制器来显示图书内容。

您可以在下面看到一张图片,当您点按书籍时,它就是书架,然后必须放大书籍照片,然后在新视图控制器中打开图书内容。

enter image description here

1 个答案:

答案 0 :(得分:1)

尝试使用此代码进行缩放单元格和转移视图.. EventlistCollection是我的Collectionview ..

  var extraview : UIView = UIView()



func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){

        self.animateZoomforCell(DemoCollectionview.cellForItemAtIndexPath(indexPath)!)
        extraview = UIView.init(frame: CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height))
        extraview.backgroundColor = UIColor.clearColor()
         extraview.addSubview(DemoCollectionview.cellForItemAtIndexPath(indexPath)!)
        self.view.addSubview(extraview)
}



func animateZoomforCell(zoomCell: UICollectionViewCell) {
        UIView.animateWithDuration(0.5, delay: 0, options: .CurveEaseOut, animations: {() -> Void in
            let x = zoomCell.frame.size.width / 2
            let y = zoomCell.frame.size.height / 1.5
            zoomCell.transform = CGAffineTransformMakeScale(x, y)
            }, completion: {(finished: Bool) -> Void in

               self.animateZoomforCellremove(zoomCell)
 })
    }
 func animateZoomforCellremove(zoomCell: UICollectionViewCell) {
        UIView.animateWithDuration(0.5, delay: 0, options: .CurveEaseOut, animations: {() -> Void in
            zoomCell.transform = CGAffineTransformMakeScale(1.0, 1.0)
            }, completion: {(finished: Bool) -> Void in

               self.extraview.removeFromSuperview()
               self.DemoCollectionview.reloadData()

        })
    }

此代码帮助您,然后请给我投票。谢谢。