在界面生成器中构建可拉伸图像
我正在尝试在界面生成器中构建可拉伸的图像。这可能吗?我在网上搜索过,但无法找到合适的解决方案。如果有任何答案,我将不胜感激。
I am trying to build a stretchable image in interface builder. Is this even possible? I have searched the web and cannot come up with a proper solution. I'd appreciate any answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可以在界面生成器中完成: http://www .slideshare.net/mystcolor/stretchable-images-in-uiimageview-using-ib-only
This can be done in interface builder: http://www.slideshare.net/mystcolor/stretchable-images-in-uiimageview-using-ib-only
如果你的意思是你已经有一个可拉伸的图像,你可以使用IB的拉伸功能。 X 和 Y 值似乎是拉伸起始点相对于图像整个宽度和高度的位置,即 0.5 表示图像中间的点。
宽度和高度也是如此:可拉伸区域的大小,相对于图像大小,即将其值设置为 1 / imageWidth 将意味着可拉伸区域的宽度为 1 像素。奇怪的是 0 对于蓝色药丸按钮也可以正常工作(可能是为了方便的原因?)。
下面,视图模式设置为“缩放至填充”。这些图像是来自 https://github.com/0xced/UIKit-Artwork-Extractor。
此答案的灵感来自 http://www.slideshare.net/mystcolor/stretchable-images-in-uiimageview-using-ib-only
If you mean you already have a stretchable image, you can use the Stretching feature of IB. The X and Y values seem to be the positions for the stretch starting point, relative to the entire width and height of the image, i.e. 0.5 would mean a point in the middle of the image.
Same thing for the Width and Height: sizes for the stretchable area, relative to the image size, i.e. setting it to a value of 1 / imageWidth would mean the stretchable area is 1 pixel wide. The strange thing is 0 also work fine for the blue pill button (could be for convenience reasons?).
Below, view modes are set to "Scale to Fill". The images are stretchable images from https://github.com/0xced/UIKit-Artwork-Extractor.
This answer was inspired by http://www.slideshare.net/mystcolor/stretchable-images-in-uiimageview-using-ib-only
在 iOS7 中,您现在可以选择在 Xcode5 xcassets 目录中使用切片。然后,当您添加切片图像时,拉伸将会为您完成。 (请参阅官方文档)
With iOS7 you now have the option to use slicing within the Xcode5 xcassets catalogue. Then the stretching will be done for you when you add the sliced image. (see official documentation)
不,那不可能。
No, that's not possible.