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

Passing Variables to Layouts #67

Closed
drosenstark opened this issue Jan 26, 2015 · 3 comments
Closed

Passing Variables to Layouts #67

drosenstark opened this issue Jan 26, 2015 · 3 comments

Comments

@drosenstark
Copy link

I'm trying to do this type of thing

    layout(splitView, boxStatus) { split, box in
        box.height == 31
        split.height == box.superview!.height - 31
        split.bottom == box.top
    }

which works, but I'd like to parameterize this so the 31 is a variable. (I'm not even able to use box.height in the second line.)

Hints, please, or is this a limitation of the framework?

Thanks!

@robb
Copy link
Owner

robb commented Jan 26, 2015

you need to cast your variable to Float, as per #56. So

layout(splitView, boxStatus) { split, box in
    box.height == CGFloat(someVar)
    split.height == box.superview!.height - CGFloat(someVar)
    split.bottom == box.top
}

should do the trick

@drosenstark
Copy link
Author

Wow, okay! I'm using Float(someVar) instead of CGFloat but it all works now. Thanks for responding (and for Cartography, again)!

@drosenstark
Copy link
Author

Would be nice to have a FAQ instead of having to look through issues. Not sure if GitHub does that....

@robb robb closed this as completed Feb 3, 2015
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