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

Cannot reuse initialViewLayoutAttributes? #26

Open
liuxuan30 opened this issue Apr 23, 2015 · 3 comments
Open

Cannot reuse initialViewLayoutAttributes? #26

liuxuan30 opened this issue Apr 23, 2015 · 3 comments

Comments

@liuxuan30
Copy link

I tried to reuse initialViewLayoutAttributes like below:
I have two subviews, and each time I just reuse the initial and final layout attributes. However at run time, I found the self.titleView's initial frame is already same as self.navigationCollectionView.

I had to create two copies for each view, and the titleView frame is correct then. Is this a bug?

    // configure layout attributes for titleView
    BLKFlexibleHeightBarSubviewLayoutAttributes *initialViewLayoutAttributes = [[BLKFlexibleHeightBarSubviewLayoutAttributes alloc] init];
    initialViewLayoutAttributes.frame = CGRectMake(0,0,self.view.bounds.size.width,64);
    BLKFlexibleHeightBarSubviewLayoutAttributes *finalViewLayoutAttributes = [[BLKFlexibleHeightBarSubviewLayoutAttributes alloc] initWithExistingLayoutAttributes:initialViewLayoutAttributes];
    finalViewLayoutAttributes.transform = CGAffineTransformMakeTranslation(0, -44);
    [self.titleView addLayoutAttributes:initialViewLayoutAttributes forProgress:0.0];
    [self.titleView addLayoutAttributes:finalViewLayoutAttributes forProgress:1.0];

    // configure layout attributes for navigationCollectionView
    initialViewLayoutAttributes.frame = CGRectMake(0,64,self.view.bounds.size.width,44);
    finalViewLayoutAttributes = [[BLKFlexibleHeightBarSubviewLayoutAttributes alloc] initWithExistingLayoutAttributes:initialViewLayoutAttributes];
    finalViewLayoutAttributes.transform = CGAffineTransformMakeTranslation(0, -44);
    [self.navigationCollectionView addLayoutAttributes:initialViewLayoutAttributes forProgress:0.0];
    [self.navigationCollectionView addLayoutAttributes:finalViewLayoutAttributes forProgress:1.0];
@palcalde
Copy link

From what I've seen is the way the library works, is not a bug. It doesn't make a copy of the layout attributes everytime you add one to a view, so yes, you need to do a new one for each.

@bryankeller
Copy link
Owner

That's correct. Theres a convenience initializer for BLKFlexibleHeightBarSubviewLayoutAttributes To init a new set of layout attributes exactly like an existing one. See initWithExistingLayoutAttributes

@liuxuan30
Copy link
Author

do you consider make it re-usable? kind of verbose when adding the attributes

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

3 participants