Можно ли расположить элемент вне экрана, используя язык визуального формата?

Я получаю ошибку, когда я пытаюсь это:

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 

0 ответов

Другие вопросы по тегам