visual-format-language

Swift Safe Area Layout Guide and Visual Format Language

一世执手 提交于 2019-11-29 16:27:53
问题 I want to use Apples visual format language to constrain a view to the new Safe Area Layout Guide in iOS 11. However, I get an exception: -[NSLayoutYAxisAnchor nsli_superitem]: unrecognized selector sent to instance 0x1c447ed40 //Make View Dictionary var views: [String: Any] = ["left": self.leftContainer] //Check swift version and add appropriate piece to the view dictionary if #available(iOS 11, *) { views["topGuide"] = self.view.safeAreaLayoutGuide.topAnchor }else{ views["topGuide"] = self

Centering a view in its superview using Visual Format Language

余生长醉 提交于 2019-11-27 10:00:51
I just started learning AutoLayout for iOS and had a look at Visual Format Language. It all works fine except for one thing: I just can't get a view to center within its superview. Is this possible with VFL or do I need to manually create a constraint myself? Currently, no, it doesn't look like it is possible to center a view in the superview using only VFL. It is, however, not that difficult to do it using a single VFL string and a single extra constraint (per axis): VFL: "|-(>=20)-[view]-(>=20)-|" [NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterX relatedBy

Centering a view in its superview using Visual Format Language

与世无争的帅哥 提交于 2019-11-26 14:59:02
问题 I just started learning AutoLayout for iOS and had a look at Visual Format Language. It all works fine except for one thing: I just can't get a view to center within its superview. Is this possible with VFL or do I need to manually create a constraint myself? 回答1: Currently, no, it doesn't look like it is possible to center a view in the superview using only VFL. It is, however, not that difficult to do it using a single VFL string and a single extra constraint (per axis): VFL: "|-(>=20)-