简体   繁体   English

调用UIButton:setImage:forState使按钮标题消失

[英]Calling UIButton:setImage:forState makes button title disappear

If I call UIButton:setImage:forState then the title text of my buttons is disappearing (set via UIButton:setTitle:forState ). 如果我调用UIButton:setImage:forState则按钮的标题文本将消失(通过UIButton:setTitle:forState )。

If I don't call setImage:forState then the title appears perfectly. 如果我不调用setImage:forState则标题会完美显示。

If I set the button images in interface builder then the title does appear, so why does setting the images programmatically cause the titel to vanish? 如果我在界面生成器中设置按钮图像,那么标题确实会出现,那么为什么以编程方式设置图像会导致标题消失?

而不是调用setImage:forState:应该调用setBackgroundImage:forState:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM