最新消息:VPS服务器又从fzhost.net换回Linode了,主题仍用朋友推荐的大前端D8

[已解决]swift给UIButton添加图像

Swift crifan 152浏览 0评论

之前已经:

                    let removeBadgeButton:UIButton = UIButton()
                    removeBadgeButton.setBackgroundImage(UIImage(named: "remove_badge"), forState: UIControlState.Normal)
                    removeBadgeButton.tag = indexPath.row
                    removeBadgeButton.addTarget(self, action: Selector("removeSelectedPerson:"), forControlEvents: UIControlEvents.TouchUpInside)
                    cell.contentView.addSubview(removeBadgeButton)

了,但是感觉:

在当前的CollectionViewCell中添加的这个button,点击对应按钮所属于的区域内时,竟然没响应。。

猜测是不是button加了setBackgroundImage,效果不太好,影响按钮点击啊

所以去搜:

swift UIButton add image

参考:

ios – How to change UIButton image in Swift – Stack Overflow

ios – Create a button programmatically and set a background image – Stack Overflow

ios – How to change UIButton image after clicking in Swift? – Stack Overflow

好些没变化:

看来不是UIButton的事情,而是UICollectionViewCell中subview中button不方便点击到的事情

转载请注明:在路上 » [已解决]swift给UIButton添加图像

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
18 queries in 0.201 seconds, using 9.87MB memory