如何在uicollectionview中放大单元格的内容

时间:2016-12-01 11:40:13

标签: ios objective-c uicollectionview uicollectionviewcell uicollectionviewlayout

enter image description here

在上图中,A,B,C,D,E是集合视图的每个自定义单元格,我想像c单元格一样逐个放大单元格。

有什么建议吗?

2 个答案:

答案 0 :(得分:2)

只需在您的collectionviewcell点击

时调用此方法
int width = view->verticalHeader()->width() + view->horizontalHeader()->width() + view->frameWidth()*2;
int height= view->horizontalHeader()->height() + view->verticalHeader()->height() + view->frameWidth()*2;

答案 1 :(得分:1)

基于Himanshu Moradiya解决方案的 swift 3

 func animateZoomforCell(zoomCell : UICollectionViewCell)
{
    UIView.animate(
        withDuration: 0.2,
        delay: 0,
        options: UIViewAnimationOptions.curveEaseOut,
        animations: {
                        zoomCell.transform = CGAffineTransform.init(scaleX: 1.2, y: 1.2)
            },
    completion: nil)
}
func animateZoomforCellremove(zoomCell : UICollectionViewCell)
{
    UIView.animate(
        withDuration: 0.2,
        delay: 0,
        options: UIViewAnimationOptions.curveEaseOut,
        animations: {
            zoomCell.transform = CGAffineTransform.init(scaleX: 1.0, y: 1.0)
    },
        completion: nil)

}