2017-05-08 82 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 
}() 

當你設置標題標題文本不配合到按鈕框架,因此你看到三個虛線。