gpt4 book ai didi

ios - 快速为常规按钮提供条形按钮标识符

转载 作者:搜寻专家 更新时间:2023-11-01 05:40:33 27 4
gpt4 key购买 nike

我想要一个不是栏按钮项的按钮来显示垃圾桶图标。有谁知道如何以编程方式执行此操作?

最佳答案

添加你的 Action :

func buttonAction(sender:UIButton!)
{
println("Button tapped") // add your button tapped logic here
}

然后在viewDidLoad里面:

    var image: UIImage = UIImage(named: "Icon")!  //Icon = your image name, no need for the extension
let button = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton //UIButton type must be CUSTOM or you will get a plain blue system button
button.frame = CGRectMake(100, 100, 100, 50) // Size and Co-ordinates
button.setImage(image, forState: .Normal) //for normal non touched state
button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) // "buttonAction" received here

self.view.addSubview(button) //adds subview to display the button

关于ios - 快速为常规按钮提供条形按钮标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31096951/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com