Quote:
Originally Posted by deeptika
Hi,
How to create custom button based on text size.I have three images they are left,right and center strip image . I have to create an button by join three images when the text size can be increased then the button can be created based on that size.Please any body help me to find the solution i have tried for two days but still i didn't get any solution.Please somebody help me to solve this problem.
|
Some methods can be used. As I understand that you want a button whose image is a combination of three other images, you can follow these next steps:
1. Build a view with the final size you want and add the three images as image views on it. Of course, each one with its well calculated frame.
2. Get the image from the view with this code:
Code:
UIGraphicsBeginImageContext(myViewWith3Images.bounds.size);
[pictureView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *buttonImage = UIGraphicsGetImageFromCurrentImageContext();
3. Create the button and set the image.
You can also use stretchable images as you know. But as you say you have to use three images I suppose that is not a solution for you.