Objective-C 在一个轴上缩放背景
你好 我有一个背景图案图像(垂直线),例如:
llllllllllllllllllllllllllll
这条线是图案图像:
bgimg.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"pd_line2.png"]];
我的问题: 我想重新构建 bgimg - 它应该在 x 轴上重复该线:但在 y 轴上拉伸该线。
下一个问题:图案图像也使用 Alpha 通道。
这可能吗? 有人可以给我提示吗?
提前致谢
hi
i have a background pattern image (vertical lines) like:
llllllllllllllllllllllllll
the line is a pattern image:
bgimg.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"pd_line2.png"]];
my problem:
i would like to reframe the bgimg - it should repeat the line on x-axis: but stretch the line on y-axis.
next problem: the pattern image also uses an alpha channel.
is this possible?
can someone please give me a hint?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,您可以通过 GCContext 函数以各种方式缩放图像,但也许更简单的方法是使视图透明(clearColor 背景)并在下面添加一个额外的 UIImageView(其中包含 pd_line2.png)。
UIImageView 的内置拉伸选项可能足以实现您所需要的功能,而无需任何编码。
Well you can certainly scale the image in various ways via GCContext functions, but perhaps the easier way would be making your view transparent (clearColor background) and adding an extra UIImageView (with pd_line2.png in it) underneath.
UIImageView's built-in stretching options may be enough to achieve what you need without any coding.