这些只是 2 张图片。一个有影子一个没有……</p>
您必须使用 CapInsets 创建这些图像以使其可调整大小
例如
UIImage *buttonImage = [[UIImage imageNamed:@"yourImage"]
resizableImageWithCapInsets:UIEdgeInsetsMake(1, 11, 0, 20)];
要了解 UIEdgeInsets 的工作原理,请阅读:
UIEdgeInsetsMake 是如何工作的?
或在 Apple Doc 中:
UIEdgeInsetsMake
Creates an edge inset for a button or view.
UIEdgeInsets UIEdgeInsetsMake (
CGFloat top,
CGFloat left,
CGFloat bottom,
CGFloat right
);
Parameters
top
The inset at the top of an object.
left
The inset on the left of an object
bottom
The inset on the bottom of an object.
right
The inset on the right of an object.
Return Value
An inset for a button or view
Discussion
An inset is a margin around the drawing rectangle where each side (left, right, top, and bottom) can have a different value.
Availability
Available in iOS 2.0 and later.
See Also
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html