UIbutton扩大触摸响应区域

  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,并且将图片设置成居中.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容