开发者

How do I add a title to a button which has a custom image?

开发者 https://www.devze.com 2023-04-12 19:48 出处:网络
I made a button with IB then added custom images for different states but my title never appears on my button. How can I fix it? In fact, I just want to add 开发者_Python百科my text over the image.You

I made a button with IB then added custom images for different states but my title never appears on my button. How can I fix it? In fact, I just want to add 开发者_Python百科my text over the image.


You can set your button images as background images in interface builder, then the text will appear.


It will not appear because the image is on top of it, you can either:

1) Use backgroundImage instead of image

2) Create an image with the text already on it

3) Create a button with a transparent part where the text will go

4) Have your image and your text in the button, but say one on the left and one on the right, you can do this with this properties: titleEdgeInsets and imageEdgeInsets

5) Add the label and uiimage as subviews of uilabel.


start with a regular button type in the title and switch it to a custom button, if you want the background to be changed import and use the command yourButton.backgroundColor = [UIColor grayColor];


Try to change the Button type to "Custom" and then add the image as Background Image. Now u will be able to see the desired look.

0

精彩评论

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