ios - Syntax for Swift 3 AddConstraintWithFormat? -


i found sourcode:

view.addconstraintswithformat("h:|[v0]|", views: menubar) view.addconstraintswithformat("v:|[v0(50)]", views: menubar) 

and i'm using swift 3, it's not working in xcode 8

can tell me code ?

thank much!

you should write function this:

   func addcontraintswithformat(_ format: string, views: uiview...) {         var viewdict = [string: uiview]()          (index, view) in views.enumerated() {             let key = "v\(index)"             view.translatesautoresizingmaskintoconstraints = false             viewdict[key] = view         }          addconstraints(nslayoutconstraint.constraints(withvisualformat: format, options: nslayoutformatoptions(rawvalue: 0), metrics: nil, views: viewdict))     } 

it work you!

may need visual format language use function.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -