ios - How do I programmatically make this auto layout? -


how make label auto layout devices.

        golabel = uilabel(frame: cgrectmake(30, 100, 350, 100))         golabel.text = "game over"         golabel.textcolor = uicolor.whitecolor()         golabel.font = uifont(name: "applesdgothicneo-thin" , size: 70)         self.view.addsubview(golabel) 

let golabel = uilabel()  golabel.settranslatesautoresizingmaskintoconstraints(false)  let horizontalconstraint = nslayoutconstraint(item: golabel, attribute: nslayoutattribute.leading, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.leading, multiplier: 1, constant: 30) view.addconstraint(horizontalconstraint)  let verticalconstraint = nslayoutconstraint(item: golabel, attribute: nslayoutattribute.top, relatedby: nslayoutrelation.equal, toitem: view, attribute: nslayoutattribute.top, multiplier: 1, constant: 100) view.addconstraint(verticalconstraint)  let widthconstraint = nslayoutconstraint(item: golabel, attribute: nslayoutattribute.width, relatedby: nslayoutrelation.equal, toitem: nil, attribute: nslayoutattribute.notanattribute, multiplier: 1, constant: 350) golabel.addconstraint(widthconstraint)  let heightconstraint = nslayoutconstraint(item: golabel, attribute: nslayoutattribute.height, relatedby: nslayoutrelation.equal, toitem: nil, attribute: nslayoutattribute.notanattribute, multiplier: 1, constant: 100) golabel.addconstraint(heightconstraint) 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -