I'm trying to make a new layout for my buttons.
Actualy when you set up a Custom UIButton
with an image and a title, the two elements are on a line.
But, on my view I need to have the title under the image.
I've try to do it with the "Edge Inset" property, and it work.
There is a way to do it with a subclass of UIButton
?
And how to do it?
thanks in advence!
Gwennin
edit:
I have made like Jano propose in comment
code to generate the background image:
+(UIImage*)drawText:(NSString*)text inImage:(UIImage*)image {
UIFont *font = [UIFont boldSystemFontOfSize:16];
CGSize size = CGSizeMake(200, 200);
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(100 - (image.size.width / 2), 0, image.size.width, image.size.height)];
CGRect rect = CGRectMake(100 - ([text length] * 8) / 2, image.size.height, 200, 200);
[[UIColor whiteColor] set];
[text drawInRect:CGRectIntegral(rect) withFont:font];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Thanks to everyone!