2017-05-08 69 views
0

我试图覆盖在聊天细胞表演图像(UICollectionView细胞)随机三个点按钮

以下的UIImage这是我使用的按钮:playButton

不过,我注意到有这样的效果每个图片我使用。以下是我正在构建的按钮的代码。

let playButton: UIButton = { 
    let button = UIButton(type: .system) 
    button.setTitle("Play Video", for: .normal) 
    button.translatesAutoresizingMaskIntoConstraints = false 
    button.isUserInteractionEnabled = true 
    let image = UIImage(named: "play") 
    button.tintColor = UIColor.white 
    button.setImage(image, for: .normal) 
    return button 
}() 

这就是它看起来像在模拟器:

Screenshot from the simulator

为什么我的UIImage的追加这些点?

+1

删除UIButton的setTitle,因为您不需要为Play Image显示文本。 –

+0

它是按钮的标题,从'playButton'中删除这行代码'button.setTitle(“播放视频”,用于:.normal)'@Ricky Avina –

回答

4

尝试了这一点:

let playButton: UIButton = { 
    let button = UIButton(type: .system) 
    button.translatesAutoresizingMaskIntoConstraints = false 
    button.isUserInteractionEnabled = true 
    let image = UIImage(named: "play") 
    button.tintColor = UIColor.white 
    button.setImage(image, for: .normal) 
    return button 
}() 

当你设置标题标题文本不配合到按钮框架,因此你看到三个虚线。