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

View in background #36

Closed
pikanezi opened this issue May 2, 2016 · 4 comments
Closed

View in background #36

pikanezi opened this issue May 2, 2016 · 4 comments

Comments

@pikanezi
Copy link

pikanezi commented May 2, 2016

Hello,
Thank you for your work, this library made me want to code my views (instead of using IB).

I have a question though, how would you create a layout where you would have an image which fill the whole background and still render views on front of it.

I really like the feeling that every views in the screen are in one unique place (layout()) but I'm afraid that it's not possible in this case.

Thank you,

Vincent

@s4cha
Copy link
Member

s4cha commented May 2, 2016

Hi @pikanezi,
Thank you for choosing code over XML :p
layout() is the preferred way of laying things out vertically but it's totally fine having things outside of a layout block :)
In your case you need image.fillContainer(), which is the equivalent of :

layout(
  0,
  |image|,
  0
)

Hope it helps ;)

@pikanezi
Copy link
Author

pikanezi commented May 2, 2016

Thank you @s4cha,

What if I want to add something on top of this image?

Thank you for your help and time, I really appreciate it :)

Vincent

@s4cha
Copy link
Member

s4cha commented May 3, 2016

@pikanezi

Just make sure the views in sv() are in the right order to make sure your background is at the back.
And then layout things the way you would normally do :)

sv(
    backgroundImage,
    label,
    separator
)

backgroundImage.fillContainer()
layout(
    label,
    13,
    |separator| ~ 2,
    0
)

@pikanezi
Copy link
Author

pikanezi commented May 3, 2016

Oh I see! Thank you for your help :)

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