0
votes

I want to use uibutton which has custom text like screen shot shows. In screen shot I added 2 uilabel to text "Module 1" and "Fungi & Fungal Infections" but and orange background is uibutton but when I press down is it shows that It only press orange button and not text. What I want that I'll set these to label to uibutton text so that It'll show that when button press down then text should have same effect like button's titleFungi Image. How this possible kindly guide me on this, this will be great for me. Thanks in advance.

2
better way to set image as you shownPreetam Jadakar
No, I don't want to use image. Is there any possibility to achieve this target?josh

2 Answers

2
votes

Is easy, just create label with attributed text that you want and add it to uiButton as subview, like this. Button set to custom type in storyboard.

UILabel * label = [UILabel new];
label.backgroundColor = [UIColor redColor];
label.text = @"Custom text";
[label sizeToFit];
label.frame = _button.bounds;
[_button addSubview:label];
0
votes

You need to select UIButton type custom and uncheck 'Highlight adjusts image' You can refer this image It will help you. :) Restrict UIButton Highlight state