开发者

Why does my UIButton.titleLabel.text disappear when I place an image in the button?

开发者 https://www.devze.com 2022-12-26 20:13 出处:网络
I\'ve had this problem before but was able to work around it until now, Basically I\'m creating a custom UIbutton setting its image as a uiimage and then the button that has had a label until I implim

I've had this problem before but was able to work around it until now, Basically I'm creating a custom UIbutton setting its image as a uiimage and then the button that has had a label until I implimented the b开发者_如何学运维elow code now loses its label. I need that label because it is set programatically in code that follows.

 NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ];
            UIImage *image = [UIImage imageNamed:imageName];
            [button setImage:image forState:UIControlStateNormal ];

Any help you could lend would be mucho appreciated.

-nick


I needed to do a:

[button setBackroundImage:image forState:UIControlStateNormal ];

instead of this:

[button setImage:image forState:UIControlStateNormal ];

;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号