1. 程式人生 > >【swift系列之UIButton】簡單使用

【swift系列之UIButton】簡單使用

override func viewDidLoad() {
        super.viewDidLoad()

        let button = UIButton.buttonWithType(UIButtonType.System) as! UIButton
        button.frame = CGRectMake(100, 100, 80, 50)
        button.backgroundColor = UIColor.orangeColor()
        button.setTitle("選照片", forState: UIControlState.Normal)
        button.addTarget(self, action: "clickBtn:", forControlEvents: UIControlEvents.TouchUpInside)
        self.view.addSubview(button)
    }
    func clickBtn(sender:UIButton){
        self.fromAlbum()
    }