2
我正在學習從代碼編寫約束VFL如何寫一個topLayoutGuide約束在VFL
我有水平居中我認爲這樣的:
let constraintY = NSLayoutConstraint.constraintsWithVisualFormat(
"H:[superview]-(<=1)-[collaboratorView]",
options: NSLayoutFormatOptions.AlignAllCenterY,
metrics: nil,
views: ["superview":self.assetsView, "collaboratorView":collaboratorView])
,但我不知道怎麼寫約束topLayoutGuide 看起來在故事板那樣
我已經結束了這樣的事情,但它不能正常工作;(
let bar = NSLayoutConstraint.constraintsWithVisualFormat(
"V:|[collaboratorView]",
options: [NSLayoutFormatOptions.AlignAllTop],
metrics: nil,
views: ["collaboratorView":self.collaboratorView])
謝謝了很多,還有一個問題 我總是想,如果這裏的topLayoutGuide什麼:「topLayoutGuide」:topLayoutGuide, 您可以加入實施請問你的答案? –
實施它,你會看到它是什麼。這是UIViewController中的一個定義的屬性, –
哦,我錯過了我在UIView裏面,無論如何你的答案是正確的;) –