簡體   English   中英

如何將按鈕的背景圖像設置為空

[英]how to set a background image of a button to nothing

在我的 swift 代碼中,我想要一個 state 來自不顯示圖像的按鈕。 它應該是完全空白的。 我嘗試使用下面的 swift 代碼來做到這一點,但我收到一條錯誤消息 no matches in call to initializer。

 BTN.setImage(UIImage(nil), for: .selected)

您希望整個圖像為零,而不是將 nil 傳遞給 UIImage 初始化程序。 嘗試這個:

BTN.setImage(nil, for: .selected)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM