iPhone SDK: UIButton with both image and text possible?

I have a button of size width 200 and height 270. I want to have text and image on the same button. Not as a background image on that text. Instead of this, I want to display the text with height 120 and image of height 150 on the same button. Anybody have ideas for it? Please let me know if you don't understand my question.


You can use this code,it will serve your purpose

.h file code
IBOutlet UIButton *testBtn;

.m file code
[testBtn setImage: [UIImage imageNamed:@"Image name.png"] forState:UIControlStateNormal];
[testBtn setTitleEdgeInsets:UIEdgeInsetsMake(70.0, -150.0, 5.0, 5.0)];
[testBtn setTitle:@"Your text" forState:UIControlStateNormal];

Adjust the coordinates and size of your button as your requirement.This is a sample code to guide you.

PS:Take a UIButton in the nib file>Make it a custom button>Connect the IBOutlet to your custom button in the nib file.Thats it.

Need Your Help

How to allocate user space buffer in kernel driver?

c linux linux-kernel linux-device-driver

In some mess up i need to call one kernel function who is not suppose to call from kernel space because in argument it takes buffer from user space allocated.

angularjs + requirejs = Argument 'controller' is not a function, got undefined

javascript angularjs requirejs lazy-loading

Hi i am trying to implement angularjs + requirejs but i get Argument 'HelloWorld' is not a function, got undefined error when i go to desired path