ios - NSLayoutConstraint with VFL is working only horizontally when using '|' -
i have following implementation of uiview..
struct loginview { let loginview: uiview = uiview() func layoutloginview() -> uiview { loginview.translatesautoresizingmaskintoconstraints = false loginview.backgroundcolor = uicolor.purple return loginview } } then, subview above in viewcontroller below..
class loginvc: uiviewcontroller { private let instanceofloginview = loginview() override func loadview() { super.loadview() view.addsubview(instanceofloginview.layoutloginview()) nslayoutconstraint.activate(nslayoutconstraint.constraints(withvisualformat: "h:|-[loginview]-|", options: [], metrics: [:], views: ["loginview":instanceofloginview.layoutloginview()])) nslayoutconstraint.activate(nslayoutconstraint.constraints(withvisualformat: "v:|-[loginview]-|", options: [], metrics: [:], views: ["loginview":instanceofloginview.layoutloginview()])) } the problem 'h' side of nslayout working -check screenshot below-. 'v' not working.
however, when apply following "v:|-8-[loginview]-8-|", works!!!
could advise why doesn't "v:|-[loginview]-|" work, please..?
appreciate help!
when using vfl, - character means "use standard spacing".
in case:
"h:|-[loginview]-|" "v:|-[loginview]-|" you saying "use layout margins" are, default:
uiedgeinsets(top: 0.0, left: 16.0, bottom: 0.0, right: 16.0) prior ios 11 .layoutmargins of root view managed view controller cannot changed. purple view cover full view, change vfl to:
"h:|[loginview]|" "v:|[loginview]|" 
Comments
Post a Comment