Faire un UIButton par programmation dans Swift

Je suis en train de construire l'INTERFACE du programme. Comment puis-je obtenir cette action de travail? Je suis en train d'élaborer avec Swift.

Code dans le viewDidLoad:

override func viewDidLoad() {
        super.viewDidLoad()
        //Do any additional setup after loading the view, typically from a nib.
        let myFirstLabel = UILabel()
        let myFirstButton = UIButton()
        myFirstLabel.text = "I made a label on the screen #toogood4you"
        myFirstLabel.font = UIFont(name: "MarkerFelt-Thin", size: 45)
        myFirstLabel.textColor = UIColor.redColor()
        myFirstLabel.textAlignment = .Center
        myFirstLabel.numberOfLines = 5
        myFirstLabel.frame = CGRectMake(15, 54, 300, 500)
        myFirstButton.setTitle("✸", forState: .Normal)
        myFirstButton.setTitleColor(UIColor.blueColor(), forState: .Normal)
        myFirstButton.frame = CGRectMake(15, -50, 300, 500)
        myFirstButton.addTarget(self, action: "pressed", forControlEvents: .TouchUpInside)
        self.view.addSubview(myFirstLabel)
        self.view.addSubview(myFirstButton)
    }

        func pressed(sender: UIButton!) {
            var alertView = UIAlertView();
            alertView.addButtonWithTitle("Ok");
            alertView.title = "title";
            alertView.message = "message";
            alertView.show();
        }
InformationsquelleAutor Benr783 | 2014-06-08