gpt4 book ai didi

ios - 具有透明背景图像的 UIButton 无法正常工作

转载 作者:搜寻专家 更新时间:2023-11-01 06:21:26 25 4
gpt4 key购买 nike

我创建了带有透明 PNG 的 UIButton。

 instantHelpBtn = UIButton()
instantHelpBtn.frame = CGRectMake(10, 10, 30, 30)
instantHelpBtn.setBackgroundImage(UIImage(named: "questions1.png"), forState: .Normal)
instantHelpBtn.addTarget(self, action: "instantHelpBtnPressed", forControlEvents: .TouchUpInside)
self.view.addSubview(instantHelpBtn)

问题是函数 instantHelpBtnPressed 仅在我以某种方式按下背景图像的非透明部分时才起作用。如果我错过了(而且我经常错过),什么也不会发生。我怎样才能改变这种行为?

最佳答案

问题出在您的按钮框架上。您正在创建 30X30 UIButton,根据 Apple iOS 人机界面指南,最小尺寸应为 44X44

关于ios - 具有透明背景图像的 UIButton 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33369802/

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