Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
stretchableImageWithLeftCapWidth:topCapHeight:, доступный аж с iOS 2.0.- (UIButton*) stretchableButton
{
UIImage* backgroundImageNormal = [[UIImage imageNamed:@"navigation_button.png"] stretchableImageWithLeftCapWidth:18 topCapHeight:0];
UIImage* backgroundImageHighlighted = [[UIImage imageNamed:@"navigation_button.png"] stretchableImageWithLeftCapWidth:18 topCapHeight:0];
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:normalImage forState:UIControlStateNormal];
[button setImage:highlightedImage forState:UIControlStateHighlighted];
[button setBackgroundImage:backgroundImageNormal forState:UIControlStateNormal];
[button setBackgroundImage:backgroundImageHighlighted forState:UIControlStateHighlighted];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont boldSystemFontOfSize:12.0];
[button setTitleEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
button.frame = CGRectMake(X, Y, W, backgroundImageNormal.size.height);
return button;
}
UIImage и resizableImageWithCapInsets