在 UIVIew 中平铺图像
我正在尝试为我正在制作的应用程序平铺图像。我正在制作可以设定长度的绳子。为了做到这一点,我有一个函数,它获取我的绳子长度,相应地设置框架大小,然后设置背景颜色,如下所示:(
图片是 UIView
)
picture.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Rope.png"]];
视图是空白的。我之前测试过它,通过将图片设为 UIImageView 来显示图像,并且它有效,但它不会再显示了。
编辑:我现在尝试了几种不同的平铺方法,我能得到的最好的方法是拉伸图像。我需要一种工作方法来平铺图像并将平铺图像的输出获取到 UIImage、UIImageView 或 UIView 中。
I am trying to tile an image for an app I am making. I am making rope that I can set the length for. In order to do this, I have a function that takes my rope length, sets the frame size accordingly, and then sets the background color like this:
(picture is a UIView
)
picture.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Rope.png"]];
The view is blank. I tested it before by displaying an image by making picture a UIImageView instead, and it worked, but it won't show up anymore.
EDIT: I have now tried a few different methods of tiling, the best I can get is a stretched image. I need a working way to tile an image and get the output of my tiled image into a UIImage
, UIImageView
, or UIView
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不知道我做错了什么,但它现在正在工作。
Not sure what I did wrong but it is working now.