2017-12-27 1314 views
0

我添加了2个按钮到我的情节串连图板展示的意见和喜欢NUM内,但奇怪的填充左出现和右侧的按钮内:奇怪填充用的UIButton

The problem

我的代码是:

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 


我试过make sizeToFit(),但它不起作用。还有就是我的Xcode设置:

Xcode Xcode



请帮我解决这个问题。

回答

0

我说:

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) 

和它的作品!