答案 0 :(得分:0)
尝试使用可调整大小的图像设置背景图像:
UIImage *image = [UIImage imageNamed:@"SomeBackgroundImage"];
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(image.size.height / 2, image.size.width / 2, image.size.height / 2, image.size.width / 2) resizingMode:UIImageResizingModeStretch];
[self setBackgroundImage:image forState:UIControlStateNormal];
夫特:
var image = UIImage(named: "SomeImageName")!;
image = image.resizableImageWithCapInsets(UIEdgeInsetsMake(image.size.height / 2.0, image.size.width / 2.0, image.size.height / 2.0, image.size.width / 2.0), resizingMode: .Stretch)
button.setBackgroundImage(image, forState: .Normal)