我正在尝试在聊天单元 (UICollectionView Cell) 上叠加播放图像
但是,我在使用的每张图片中都注意到了这种效果。下面是我正在构建的按钮的代码。
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
}()
当您设置标题时,标题文本不适合按钮框架,因此您会看到三条虚线。
关于ios - 按钮中 UIImage 后的随机三个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43840009/