how to make Float UIButton in programatically
Try this code in file swift or playground, this full code
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(frame: CGRect(x: view.center.x, y: view.center.y, width: 100, height: 100))
button.layer.cornerRadius = button.frame.size.height / 2
button.layer.backgroundColor = UIColor.red.cgColor
button.layer.shadowColor = UIColor.black.cgColor
button.layer.shadowOffset = CGSize(width: 0.0, height: 0.5)
button.layer.shadowOpacity = 1.0
button.layer.shadowRadius = 4.0
button.layer.masksToBounds = false
view.addSubview(button)
}
}
No comments: