Swift UIButton


        let button = UIButton(type:.system);
        button.frame = CGRect.init(x:100,y:150,width:160,height:30);
        button.setTitle("SwiftBtton", for: .normal);
        button.backgroundColor = UIColor.brown;
        button.titleLabel?.font = UIFont.systemFont(ofSize: 17);
        button.tintColor = UIColor.cyan;
        button.addTarget(self, action: #selector(buttonDidClick), for: .touchUpInside);
        self.view.addSubview(button);
        
    }
    func buttonDidClick() {
        print("按鈕被點擊了");
    }

ide

相關文章
相關標籤/搜索