如何在UIButton中以选定状态从正常状态和标题文本设置UIImage(How to set UIImage from nomal state and title text in the selec

编程入门 行业动态 更新时间:2024-10-26 22:26:14
如何在UIButton中以选定状态从正常状态和标题文本设置UIImage(How to set UIImage from nomal state and title text in the selected state in UIButton)

如何在正常状态下设置UIImage并在我的UIButton中设置选定状态的标题?

嗨,我尝试在UIButton的正常状态下设置UIImage,但是当在正常状态下设置UImage时,这会更改处于选定状态的UIButton的标题,从而更改图像的标题。 我在用

myButton setTitle:content forState:UIControlStateSelected

在选定的州。

如何在正常状态下设置UIImage并在我的UIButton中设置选定状态的标题?

PDT:对不起我的英语!

How I can set UIImage in the normal state and set title in the selected state in my UIButton?

Hi, I try to set a UIImage in the normal state of UIButton, but when set an UImage in normal state this change the title of UIButton in the selected state changing the title for the image . I am using

myButton setTitle:content forState:UIControlStateSelected

in the state selected.

How I can set UIImage in the normal state and set title in the selected state in my UIButton?

PDT: sorry for my english!.

最满意答案

检查此代码:

[myButton setTitle:content forState:UIControlStateSelected]; [myButton setImage:nil forState:UIControlStateSelected]; [myButton setImage:yourImage forState:UIControlStateNormal];

Check with this code:

[myButton setTitle:content forState:UIControlStateSelected]; [myButton setImage:nil forState:UIControlStateSelected]; [myButton setImage:yourImage forState:UIControlStateNormal];

更多推荐

本文发布于:2023-07-28 19:08:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1308210.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:状态   中以   文本   标题   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!