3

これを試すとエラーが発生します:

let space = UILayoutGuide()
view.addLayoutGuide(space)

let myFormatString = "someLabel|space-anotherLabel-|"

Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Unable to parse constraint format:  Expected a view
someLabel|space-anotherLabel  
^'

私もこれを試しました:

let myFormatString = "|-someLabel-space(==viewWidth)-anotherLabel"

...
...
                metrics: [
                    "viewWidth": view.frame.width
                ],

しかし、それはエラーを生成しました:

Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Unable to parse constraint format: 
It's not possible to set a space equal to the width or height of a view.
Perhaps you want to use a view as a spacer? 
[view1][spacer(==view1)][view2] 
|-someLabel-space(==viewWidth)-anotherLabel 
4

0 に答える 0