我在我的故事板上添加了两个按钮来显示评论和喜欢num,但是奇怪的填充显示在按钮的左边和右边:

我的代码是:
cell.btnComments.setTitle("199", for: .normal)
cell.btnComments.setImage(UIImage(named: "3.png"), for: .normal)
cell.btnComments.imageView!.contentMode = UIViewContentMode.scaleAspectFit
cell.btnLike.setTitle("19963", for: .normal)
cell.btnLike.setImage(UIImage(named: "4.png"), for: .normal)
cell.btnLike.imageView!.contentMode = UIViewContentMode.scaleAspectFit我试图使sizeToFit(),但它不起作用。这是我的Xcode设置:


请帮我解决这个问题。
发布于 2017-12-27 19:15:06
我补充说:
cell.btnComments.contentEdgeInsets = UIEdgeInsetsMake(0,-23,0,-13)
cell.btnComments.titleEdgeInsets = UIEdgeInsetsMake(0,-13,0,0)
cell.btnLike.contentEdgeInsets = UIEdgeInsetsMake(0,-23,0,-13)
cell.btnLike.titleEdgeInsets = UIEdgeInsetsMake(0,-13,0,0)而且起作用了!
https://stackoverflow.com/questions/47997065
复制相似问题