首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当点击UIcollectionviewcell时,放大单元格照片并打开新的视图控制器

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

Stack Overflow用户
提问于 2016-10-01 10:53:46
回答 1查看 2.3K关注 0票数 1

我在视图控制器中有一个UICollectionView,我需要,当我点击UICollectionViewCell时,放大单元格照片,然后打开新的视图控制器来显示图书内容。

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

​

​

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-10-01 12:06:25

试试缩放单元和传输视图的代码。EventlistCollection是我的收藏..。

代码语言:javascript
复制
  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()

        })
    }

这段代码帮了你然后请给我投票。谢谢。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39805738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档