我在视图控制器中有一个UICollectionView,我需要,当我点击UICollectionViewCell时,放大单元格照片,然后打开新的视图控制器来显示图书内容。
你可以看到下面的图片,它是一个书架,当你点击书籍时,一张书照片必须放大,然后在新的视图控制器中打开书的内容。

发布于 2016-10-01 12:06:25
试试缩放单元和传输视图的代码。EventlistCollection是我的收藏..。
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()
})
}这段代码帮了你然后请给我投票。谢谢。
https://stackoverflow.com/questions/39805738
复制相似问题