<bdo id='hjaXD'></bdo><ul id='hjaXD'></ul>

    <small id='hjaXD'></small><noframes id='hjaXD'>

    <tfoot id='hjaXD'></tfoot>

    1. <legend id='hjaXD'><style id='hjaXD'><dir id='hjaXD'><q id='hjaXD'></q></dir></style></legend>

      <i id='hjaXD'><tr id='hjaXD'><dt id='hjaXD'><q id='hjaXD'><span id='hjaXD'><b id='hjaXD'><form id='hjaXD'><ins id='hjaXD'></ins><ul id='hjaXD'></ul><sub id='hjaXD'></sub></form><legend id='hjaXD'></legend><bdo id='hjaXD'><pre id='hjaXD'><center id='hjaXD'></center></pre></bdo></b><th id='hjaXD'></th></span></q></dt></tr></i><div id='hjaXD'><tfoot id='hjaXD'></tfoot><dl id='hjaXD'><fieldset id='hjaXD'></fieldset></dl></div>
    2. 设置按钮类型

      时间:2023-07-08

      • <bdo id='Xk0UJ'></bdo><ul id='Xk0UJ'></ul>

            <tbody id='Xk0UJ'></tbody>

          <small id='Xk0UJ'></small><noframes id='Xk0UJ'>

          <legend id='Xk0UJ'><style id='Xk0UJ'><dir id='Xk0UJ'><q id='Xk0UJ'></q></dir></style></legend>
            <tfoot id='Xk0UJ'></tfoot>

              • <i id='Xk0UJ'><tr id='Xk0UJ'><dt id='Xk0UJ'><q id='Xk0UJ'><span id='Xk0UJ'><b id='Xk0UJ'><form id='Xk0UJ'><ins id='Xk0UJ'></ins><ul id='Xk0UJ'></ul><sub id='Xk0UJ'></sub></form><legend id='Xk0UJ'></legend><bdo id='Xk0UJ'><pre id='Xk0UJ'><center id='Xk0UJ'></center></pre></bdo></b><th id='Xk0UJ'></th></span></q></dt></tr></i><div id='Xk0UJ'><tfoot id='Xk0UJ'></tfoot><dl id='Xk0UJ'><fieldset id='Xk0UJ'></fieldset></dl></div>
                本文介绍了设置按钮类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在以编程方式创建一个按钮,我想知道如何设置该按钮的 UIButtonType.

                I am creating a button programatically and I would like to know how to set that button's UIButtonType.

                这就是我创建按钮的方式:

                This is how I am creating my button:

                let headerPlusButon:UIButton = UIButton(frame: CGRectMake(5, tableView.frame.width - 30, 20, 20))
                headerPlusButon.addTarget(self, action: "paymentAddButtonTapped", forControlEvents:.TouchUpInside)
                

                没有像更改标题文本那样的setButtonTypeFor..."方法,显然这不起作用:

                There is no "setButtonTypeFor..." method like how you would change the title's text and obviously this doesn't work:

                headerPlusButon.buttonType = UIButtonType.ContactAdd
                

                推荐答案

                override func viewDidLoad() {
                
                    super.viewDidLoad()
                
                    let button   = UIButton.buttonWithType(UIButtonType.System) as UIButton
                    button.frame = CGRectMake(100, 100, 100, 50)
                    button.backgroundColor = UIColor.greenColor()
                    button.setTitle("Test Button", forState: UIControlState.Normal)
                    button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
                
                    self.view.addSubview(button)
                }  
                
                func buttonAction(sender:UIButton!)
                {
                    println("Button tapped")
                }
                

                swift 2 用下面的行替换 UIButton 声明.

                from swift 2 replace UIButton declaration with below line.

                let button = UIButton(type: .System) as UIButton
                

                这篇关于设置按钮类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如果它们都具有相同的 IBAction,如何定义按下哪个按钮? 下一篇:向 UIButton 添加子视图

                相关文章

                <legend id='BnY6t'><style id='BnY6t'><dir id='BnY6t'><q id='BnY6t'></q></dir></style></legend>

                <small id='BnY6t'></small><noframes id='BnY6t'>

                <i id='BnY6t'><tr id='BnY6t'><dt id='BnY6t'><q id='BnY6t'><span id='BnY6t'><b id='BnY6t'><form id='BnY6t'><ins id='BnY6t'></ins><ul id='BnY6t'></ul><sub id='BnY6t'></sub></form><legend id='BnY6t'></legend><bdo id='BnY6t'><pre id='BnY6t'><center id='BnY6t'></center></pre></bdo></b><th id='BnY6t'></th></span></q></dt></tr></i><div id='BnY6t'><tfoot id='BnY6t'></tfoot><dl id='BnY6t'><fieldset id='BnY6t'></fieldset></dl></div>
                1. <tfoot id='BnY6t'></tfoot>

                    <bdo id='BnY6t'></bdo><ul id='BnY6t'></ul>