2016-10-01 42 views
1

我有一個UICollectionView在視圖控制器,我需要,當我點擊UICollectionViewCell,放大細胞照片,然後打開新的視圖控制器顯示書籍內容。當點擊UIcollectionviewcell放大細胞照片和打開新的視圖控制器

你可以在下面看到一個圖像,當你點擊書本時,它是一個書架,然後書本照片必須放大,然後在新視圖控制器中打開書本內容。

enter image description here

+0

你不試試嗎? –

回答

0

嘗試使用變焦細胞和轉讓鑑於這種代碼.. 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() 

     }) 
    } 

此代碼可以幫助您,那麼請給我投票。謝謝。

+0

但我需要全屏放大,然後打開視圖控制器 –

+0

@ ZanaMustafa在這個集合didselectItemAtIndexPath您的單元格縮放和縮放單元格後,您的控制器可以移動下一個詳細信息視圖控制器。所以你需要更多? –

+0

縮放單元格僅在自選區域不是全屏,或者您可以創建簡單的項目嗎? –

相關問題