2017-12-27 146 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) 

和它的作品!