Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objective-c compatibility #36

Open
CavalcanteLeo opened this issue Jan 19, 2018 · 1 comment
Open

Objective-c compatibility #36

CavalcanteLeo opened this issue Jan 19, 2018 · 1 comment

Comments

@CavalcanteLeo
Copy link

CavalcanteLeo commented Jan 19, 2018

I can't use any property in objective-c (eg: layout.animator), none of them are visible.

captura de tela 2018-01-19 as 18 56 47

@BaluNaik
Copy link

BaluNaik commented Feb 4, 2018

Create Swift Extension and import into your objective-C class

@objc public extension AnimatedCollectionViewLayout{

@objc class func initWithPageAnimator() -> AnimatedCollectionViewLayout{
    let layout = AnimatedCollectionViewLayout()
    layout.scrollDirection = .horizontal
    layout.animator = PageAttributesAnimator(scaleRate: 0.0)
    
    layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    layout.minimumInteritemSpacing = 0
    layout.minimumLineSpacing = 0
    
    return layout
}
@objc class func initWithParallaxAnimator() -> AnimatedCollectionViewLayout{
    let layout = AnimatedCollectionViewLayout()
    layout.scrollDirection = .horizontal
    layout.animator = ParallaxAttributesAnimator(speed: 0.2)
    
    layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
    layout.minimumInteritemSpacing = 0
    layout.minimumLineSpacing = 0
    
    return layout
}

}

Just use like this

self.collectionView.collectionViewLayout = (AnimatedCollectionViewLayout*)[AnimatedCollectionViewLayout initWithPageAnimator];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants