Default button Swift
look very simple.
To change text color,
font size, use this
let at=NSMutableAttributedString(string: t, attributes: [NSForegroundColorAttributeName: UIColor.blueColor(), NSFontAttributeName: UIFont(name: "Arial", size: 15.0)!])
button.setAttributedTitle(at, forState: .Normal)
To bold text
button.font = UIFont.boldSystemFontOfSize(17)
To set background color
button.backgroundColor = hex("#e6e6fa")
Hex function can see
here.
To round corner
button.layer.cornerRadius = 20
Change number index to
more or less round angle.
To make border, color
border.
button.layer.borderColor = hex("#6699cc").CGColor
button.layer.borderWidth = 1
To make 3D button, make
a 3D background image with png format. Drag it in to project, then declare an
image above viewDidLoad.
let im = UIImage(named:
"3Dfloat")
Set background to button like this.
bu1.setBackgroundImage(im,
forState: .Normal)
No comments:
Post a Comment