Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Is it possible to generate iOS autolayout code? #16

Open
caoer opened this issue Jun 5, 2016 · 3 comments
Open

Is it possible to generate iOS autolayout code? #16

caoer opened this issue Jun 5, 2016 · 3 comments
Labels

Comments

@caoer
Copy link

caoer commented Jun 5, 2016

Hi, this js lib looks very interesting. Just a question, I'm wondering if iOS code can be generated, either swift for obj-c version. So that we can write a web application and generate views can be used in iOS app. Any thoughts about it?

@IjzerenHein
Copy link
Owner

Hi, yes you could do this. When you create an Autolayout.js View, you can add constraints to it. Either by creating them explicitly or by creating them from a VFL string. Unfortunately there is no method to get the constraints from a view (yet), but you could easily keep track of the added constraints yourself.
These constraints have exactly the same properties as NSLayoutConstraint, so you could easily write some code to format them as Objective-C/Swift constraints.

@caoer
Copy link
Author

caoer commented Jun 6, 2016

Cool, this is exciting. Can you point me to the code where I can do the conversion maybe? I took a look at the source code, but not sure where is the best start point...

@IjzerenHein
Copy link
Owner

IjzerenHein commented Feb 8, 2017

Sure, that would be src/VisualFormat.js. VisualFormat.parse() parses VFL or EVFL and returns a list of objects (constraint definitions).

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

No branches or pull requests

2 participants