I have a simple button and I want to put an image inside, so I have this code:
myButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 13, 116, 138)];
UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[self.visuel lpath] ofType:@"jpg"]];
[myButton setImage:image forState:UIControlStateNormal];
in InterfaceBuilder Its easy to tell my image to take the size and width of my button but how to do
that programmatically? do I have to use myButton.contentHorizontalAlignment =….. something like that?
Best Regards,
What you probably want to do is this…
Of course the cap widths will depend on your image. It just repeats the next line of pixels over and over again until your image stretches to the proper width