-
Notifications
You must be signed in to change notification settings - Fork 0
Button 1
Mohammad Azmal Hossain edited this page Apr 6, 2017
·
1 revision
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let myButton = UIButton()
myButton.setTitle("Hai Touch Me", for: .normal)
// myButton.setTitle("✸", forState: .Normal)
myButton.backgroundColor = UIColor.blue // for background color
// myButton.setTitleColor(UIColor.blueColor, forState: .Normal)
myButton.frame = CGRect(x: 100, y: 50, width: view.frame.width - 200, height: 40)
myButton.layer.borderWidth = 1; // let myColor = UIColor(red: 0.5, green:0.5, blue: 0, alpha: 1.0) // myButton.layer.borderColor = myColor.cgColor myButton.layer.borderColor = UIColor(red: 0.5, green:0.5, blue: 0, alpha: 1.0).cgColor myButton.layer.cornerRadius = CGFloat(10)
myButton.addTarget(self, action: #selector(ViewController.pressedAction),for: .touchUpInside)
self.view.addSubview(myButton) }
func pressedAction(_sender: UIButton){
print("you clicked on button ")
}
/*
func pressedAction(sender: UIButton!) {
} */
}