美文网首页
UIbutton扩大触摸响应区域

UIbutton扩大触摸响应区域

作者: 码农老王 | 来源:发表于2018-06-04 10:23 被阅读17次
  1. 需要设置 setImage 设置setbackgroundImage 不管用
moreButton.setImage(IMAGE("comcard_icon_more_normal"), forState: .Normal)   
  1. 设置button的contentmode
moreButton.contentMode = .Center
  1. 设置对应更大的frame或者约束就可以了.
原frame: moreButton.frame = CGRectMake(4, 8, 44, 28)
新frame: moreButton.frame = CGRectMake(0, 0, 48, 44)

展示效果一样
原理: 扩大button的frame,并且将图片设置成居中.

相关文章

网友评论

      本文标题:UIbutton扩大触摸响应区域

      本文链接:https://www.haomeiwen.com/subject/jmsesftx.html