我正在使用这张图片
它在 iPhone 中运行良好,但如果我在 iPad 中使用此图像,它的边缘会被拉伸(stretch)。
我知道我可以使用 resizableImageWithCapInsets,但它对我来说效果不佳。
请建议我应该做什么以及 resizableImageWithCapInsets 的工作原理。
我目前的代码是这样的,(但它不适合我)
[[self IBimgCellBGImage]setImage:[[UIImage imageNamed:@"img_cellBGView.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 4, 1, 4)]];
最佳答案
您使用的插图太小了,它只是在角落里遮盖了一个 1 x 4 的像素。这是透明的,所以不调整大小。
你实际上只想拉伸(stretch)最中心的像素,因为你的图像像这样会做:
[[self IBimgCellBGImage]setImage:[[UIImage imageNamed:@"img_cellBGView.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(98, 150, 98, 150)]];
您甚至可能希望将图像缩小并在所有设备上拉伸(stretch)以节省空间。
关于ios - 我想让我的 UIImage 使用 resizableImageWithCapInsets 在 iPhone 和 iPad 上看起来一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29561861/