我想在滚动uicollectionview时向uicollectionview添加动画。我想在iOS上添加动画深度页面转换

时间:2016-03-24 11:57:35

标签: ios swift uicollectionview uicollectionviewcell

我想让集合视图单元格全屏,并且想要像android深度页面传输一样动画。动画必须像堆叠一样在向上滚动并向下堆叠时向上滚动。

 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    // get a reference to our storyboard cell
    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! CollectionViewCell

    // Use the outlet in our custom class to get a reference to the UILabel in the cell

    cell.backgroundColor = UIColor.yellowColor() // make cell more visible in our example project
    cell.layer.borderColor = UIColor.grayColor().CGColor
    cell.layer.borderWidth = 1
    cell.layer.cornerRadius = 8



    return cell
}
func collectionView(collectionView: UICollectionView, didHighlightItemAtIndexPath indexPath: NSIndexPath) {
    let cell = collectionView.cellForItemAtIndexPath(indexPath)
    cell?.backgroundColor = UIColor.redColor()
}

// change background color back when user releases touch
func collectionView(collectionView: UICollectionView, didUnhighlightItemAtIndexPath indexPath: NSIndexPath) {
    let cell = collectionView.cellForItemAtIndexPath(indexPath)
    cell?.backgroundColor = UIColor.yellowColor()
}
func collectionView(collectionView: UICollectionView,
    layout collectionViewLayout: UICollectionViewLayout,
    sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {

        return CGSizeMake(collectionView.bounds.size.width, collectionView.bounds.size.height)
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
    return 0
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
    return 0
}

0 个答案:

没有答案