Friday 11 July 2014

Programmatically creating button in swift language for ios

var button=UIButton(frame: CGRectMake(20, 20, 280, 40));
        button.backgroundColor=UIColor.blueColor();
        button.setTitle("ravi kumar", forState: .Normal);
        button.setTitleColor(UIColor.yellowColor(), forState: .Normal);
        button.alpha=0.2;
        button.layer.borderWidth=0.3;
        button.layer.cornerRadius=2;
        button.addTarget(self, action: "pressme", forControlEvents: .TouchUpInside);
        button.titleLabel.textAlignment=NSTextAlignment.Center;

        self.view.addSubview(button);


No comments:

Post a Comment