Pull to refresh

Comments 5

Имхо, 9-patch удобнее и нагляднее. И для замены кнопки в 9-patch не нужно править код.
9-patch, iOS — я что-то пропустил?
Пардон, плохо гуглиться с утра.
По сабжу, любая 3rd-party либа всегда будет 3rd-party, а когда есть нативные способы — это круто.
Есть метод 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;
}
Да, но проблема в том, что он depricated в iOS 5.0 и выше:

stretchableImageWithLeftCapWidth:topCapHeight:
Creates and returns a new image object with the specified cap values. (Deprecated in iOS 5.0. Deprecated. Use the resizableImageWithCapInsets: instead, specifying cap insets such that the interior is a 1x1 area.)
Sign up to leave a comment.

Articles