- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
以下代码在指定的插图内平铺图像区域:
UIEdgeInsets imgInsets = UIEdgeInsetsMake(10.f, 5.f, 13.f, 44.f);
UIImage *image = [[UIImage imageNamed:@"fileName"] resizableImageWithCapInsets:imgInsets];
然而,这仅在 iOS5 中可用。我怎样才能获得与 iOS5 之前的兼容性相同的结果?
[UIImage stretchableImageWithLeftCapWidth: topCapHeight:]
据我所知是不合适的,因为它假设可平铺区域的宽度为 1px。换句话说,它不是平铺的,而是拉伸(stretch)的。因此它不适用于图案,仅适用于单色图像。下面的屏幕截图展示了这一点。
然后是 [UIColor colorWithPatternImage:]
,但这假定整个图像需要平铺,它不允许必须保持上限的插图。
感谢任何帮助,谢谢。
.
最佳答案
我也一直在寻找解决方案。此时我想我将在原始 UIImage 上使用 respondsToSelector:@selector(resizableImageWithCapInsets:)
来查看该方法是否可用。如果不是,则使用可拉伸(stretch)图像。
我仍在寻找更好的解决方案,如果出现,我会更新答案。
关于ios - 怎么做 [UIImage resizableImageWithCapInsets :] prior to iOS5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8335347/
是否可以创建具有可调整大小图像的正确对齐 UIImageView? 我尝试了所有方法(例如图像的二次方等),但无法正常工作。 UIImageView的坐标是: po _Background (UIIm
我尝试弄清楚如何使用 resizableImageWithCapInsets: 在 UIImageView 中使下拉图像适合黑色边框(边框只是为了方便)。 我使用 AutoLayout,_imageV
我想了解 resizableImageWithCapInsets 的工作原理,所以我找到了这张图片 图像的大小是 57x51 所以我创建了这样的图像 image = [[UIImage imageWi
我想拉伸(stretch)尺寸为 170x50 的图像并将其显示在尺寸为 240x140 的 ImageView 中。原始图像如下所示: 我想保留四个角,只拉伸(stretch)中心部分。我使用以下代
我想拍这样的照片: 然后我写了代码: [[[UIImage imageNamed:@"background.png"] resizableImageWithCapInsets:UIEdgeInse
基本上,我使用的是 resizableImageWithCapInsets:UIEdgeInsetsMake。但我不确定这是否是我崩溃的根源。我正在我的表格单元格中添加这些可调整大小的图像。我不太确定
我正在使用自定义背景图像自定义 UISegmentedControl。代码是这样的: UIImage *segmentSelected = [[UIImage imageNamed:@"segcont
我需要为每个单元格创建一个非常复杂的背景图像:http://i.stack.imgur.com/PBL0S.png 它的中心有一个透明的圆圈。我的单元格的高度取决于它的内容——它可能会有所不同。但我需
我最近刚开始使用 iOS 编程,并假设我了解 Objective-C 引用计数,但似乎我没有... >(代码 1 或代码 2)。 我没有使用 ARC(基于 PhoneGap 的项目)。 for(int
好吧,我有一个 UIImageView,我想通过“animationImages”为它的图像设置动画,正如您在此处看到的那样: UIImage *img1 = [[UIImage imageNamed
在我的应用程序中,我以编程方式使用简单的纯色为标签制作背景,例如: - (UIImage*)badgeImage { static UIImage *image = nil; static dispa
我目前正在尝试在 SKSpriteNode 上使用可拉伸(stretch)图像。 通常,可伸缩图像由方法 UIImage::resizableImageWithCapInsets: 返回 所以我写了这
我是 Swift's Apple 的新手。我读过一篇来自 Here 的文章 但不知道如何做那样的事情(或者只是简单地不知道如何在 Swift 中使用 resizableImageWithCapInse
UIImage 的 resizableImageWithCapInsets 方法非常适合带圆角的标准矩形按钮,但我正在尝试创建一个看起来像云的按钮,边缘不均匀。我不太清楚绘制或创建它的最佳方式,或者当
因此,我有一个尺寸为 (640, 960) 像素的 .png 图像。我正在尝试从 .png 创建一个可调整大小的图像,以便垂直拉伸(stretch)该图像并适合 iPhone 5 的(640、1096
我有一个 png 用作另一个图像的图像蒙版。两个图像都有圆角,这些圆角使用 resizableImageWithCapInsets: 保留。图像(不是 mask )会自动调整大小,因为它是 UIPro
我有一个 UIImage 使用 resizableImageWithCapInsets 完美调整大小来制作包含文本标签的角标(Badge)。我很想知道有没有办法在 Storyboard或使用 Nib
我正在编写我的第一个 iOS 应用,目标是 iOS 5.0+ 平台。我正在使用 UIAppearance 协议(protocol)来自定义应用程序 UI。 我正在尝试更改整个应用程序中 UIBarBu
以下代码在指定的插图内平铺图像区域: UIEdgeInsets imgInsets = UIEdgeInsetsMake(10.f, 5.f, 13.f, 44.f); UIImage *image
我正在尝试创建下图的可调整大小版本(40x28,底部的小三角形应水平居中): UIEdgeInsets imageInsets = UIEdgeInsetsMake(4.0f, 4.0f, 8.0f,
我是一名优秀的程序员,十分优秀!