当前位置: 动力学知识库 > 问答 > 编程问答 >

cocoa touch - Is Visual Format Language really useful in iOS when we can make constraints and Anchors at runtime

问题描述:

Even Xcode provides very easy to use story board via which making UI of an app is quite easy.

But some time we come in situations when we have to use CODE to manage the design aspects of our app.

I generally use Anchors and Constraints to handle this stuff via code but there is also another way of doing it i.e.., "Visual Format Language". Is there really any difference between using any of the methods or they are same what are the advantages or disadvantages of using one or other.

网友答案:

The old-style NSLayoutConstraint initializer was a pain in the butt, so the visual format syntax was a welcome alternative. Now that we have another alternative, namely the Anchors notation, making a single constraint by hand is not very cumbersome, and the visual format notation is not as useful as it used to be. Moreover there are many important constraint notions that visual format syntax is incapable of expressing; this was always a shortcoming.

Nevertheless, visual format syntax is still extremely handy when you have a row (or column) of objects to configure all at once, e.g. "|-(20)-[v1]-(30)-[v2]-(20)-[v3]". This is because of the ability of one format string to generate many constraints at once.

分享给朋友:
您可能感兴趣的文章:
随机阅读: