ios - 我想让我的 UIImage 使用 resizableImageWithCapInsets 在 iPhone 和 iPad 上看起来一样

标签 ios objective-c image-processing uiimageview

我正在使用这张图片 Image to capInsets

它在 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/

相关文章:

iphone - 服务器到客户端的消息传递能否依赖 APNS?

iphone - 请求成员 'constantCoordinateValue' 不是核心情节中的结构或联合错误

python - 使用 Python 进行视网膜血管分割

c++ - 双三次插值伪影(图像高档)

c++ - 需要找到一种使用 OpenCV 在二维图像中检测息肉的方法

objective-c - iOS - touchesMoved 在子类 UIScrollView 中只调用一次

ios - 拥有可以是任何遵守特定协议(protocol)的对象的属性

iphone - iPad 中的 UIWebView 内容调整大小问题

ios - SCNNode.position 静态?

ios - 如何在每次刷新时从数组中的 UITableView 添加 30 个数据