Ios 在按钮中的UIImage后面随机添加三个点

Ios 在按钮中的UIImage后面随机添加三个点,ios,swift,uibutton,uiimage,Ios,Swift,Uibutton,Uiimage,我试图在聊天室(UICollectionView单元)上覆盖播放图像 这是我正在使用的按钮: 然而,我注意到我使用的每个图像都有这种效果。下面是我正在构建的按钮的代码 let playButton: UIButton = { let button = UIButton(type: .system) button.setTitle("Play Video", for: .normal) button.translatesAutoresizingMaskIntoConstra

我试图在聊天室(UICollectionView单元)上覆盖播放图像

这是我正在使用的按钮:

然而,我注意到我使用的每个图像都有这种效果。下面是我正在构建的按钮的代码

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
}()
这就是它在模拟器中的样子:

为什么我的UIImage会附加这些点?

试试这个:

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
}()

设置标题时,标题文本不适合按钮框架,因此可以看到三条虚线。

删除UIButton的设置标题,因为不需要显示播放图像的文本。这是按钮的标题,请删除这行代码
按钮。设置标题(“播放视频”,例如:。正常)
来自
playButton
@Ricky Avina