To make text center
label, we use this line
la.textAlignment = NSTextAlignment.Center
To make label center
screen, use this
ima.center = CGPoint(x: view.center.x, y:250)
There’s another way,
first get screen width
let r = UIScreen.mainScreen().bounds.size.width
If label width 240,
declare a variable name margin
let margin = (Int(r) - 240)/2
Use this variable to set
label margin.
la = UILabel(frame: CGRect(x: margin, y: 60, width: 240, height: 25))
This way can use to
every view when you know it’s width.
No comments:
Post a Comment