iOS11 UIBarButtonItem 间距问题
2020-11-09 本文已影响0人
茗记西岭雪
在自定义的 button 上写上如下代码 参考的 csdn 上的大佬的代码
https://blog.csdn.net/qq_30963589/article/details/80984659
let offset:CGFloat = CGFloat(8)
switch type {
case .left:
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: -offset, bottom: 0, right: offset)
case .right:
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: offset, bottom: 0, right: -offset)
}
button.translatesAutoresizingMaskIntoConstraints = false