UICollection在目标c中的“索引路径上的项目的单元格”中重新加载时查看单元格动画和转换效果

时间:2018-02-20 11:35:41

标签: ios objective-c uicollectionview uicollectionviewcell

我有集合视图和每个单元格有六个单元格的图像,它就像封面垂直效果一样出现了动画。但我需要每个单元格来自封面垂直效果和动画时间延迟。 例如如果一个单元来自覆盖垂直(它来自自下而上的效果),延时0.2 表示第二个单元来自时间延迟,同样是0.6必须 来。这就是我需要的。请帮帮我。

enter image description here

2 个答案:

答案 0 :(得分:0)

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager

        logout:       true
        anonymous:    true

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }

答案 1 :(得分:-1)

试试这个:

var isCollectionViewScrollUp: Bool = true


func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    let collectionHeight: CGFloat = self.collectionView!.bounds.size.height

    let contentOffsetY: CGFloat = self.collectionView.contentOffset.y
    let contentSizeHeight: CGFloat = self.collectionView.contentSize.height

    var height:CGFloat = 0.0//collectionHeight * CGFloat(indexPath.row)

    if isCollectionViewScrollUp && (contentOffsetY + self.collectionView.frame.size.height) < contentSizeHeight {

        let index = Int(indexPath.row) + Int(1)
        if index % 3 == 1 {
            height = collectionHeight + 300
        }
        else if index % 3 == 2 {
            height = collectionHeight + 300 * 2
        }
        else {
            height = collectionHeight + 300 * 3
        }

        cell.transform = CGAffineTransform(translationX: 0, y: height)
    } else if !isCollectionViewScrollUp && contentOffsetY > 0.0 {
        let index = Int(indexPath.row) + Int(1)
        if index % 3 == 1 {
            height = collectionHeight + 300 * 3
        }
        else if index % 3 == 2 {
            height = collectionHeight + 300 * 2
        }
        else {
            height = collectionHeight + 300
        }

        cell.transform = CGAffineTransform(translationX: 0, y: -height)
    }

    UIView.animate(withDuration: 1, delay: 0.03, usingSpringWithDamping: 0.8, initialSpringVelocity: 0, options: [], animations: {
        cell.transform = CGAffineTransform(translationX: 0, y: 0);
    }, completion: nil)

}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    let scrollVelocity:CGPoint  = self.collectionView.panGestureRecognizer.velocity(in: self.collectionView?.superview)
    if scrollVelocity.y > 0.0 { //ScrollDown
        isCollectionViewScrollUp = false
    } else if scrollVelocity.y < 0.0 { //ScrollUp
        isCollectionViewScrollUp = true
    }
}