重复图像在iOs [英] repeat image in iOs

查看:92
本文介绍了重复图像在iOs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像是1 * 90渐变,我想使用它作为背景不同的高度说例如第一行的高度90然后没有问题,但第二个是100然后第三是80 ...

I have an image which is 1*90 with gradient and i want to use it as background for different height say for example for first row of height 90 then no issues but second one is 100 then third is of 80... hw do I do this?

推荐答案

self.someImage = [[UIImage imageNamed:@"yourImage.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)];

将调整图像大小,顶部保持10像素,左边0,底部10,对。你也可以尝试

that will resize image and keep 10 pixels at top, 0 at left, 10 at bottom and 0 at right. You can also try

self.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImage.png"]] autorelease];
self.backgroundView.contentMode = UIViewContentModeScaleToFill;

希望它有帮助

这篇关于重复图像在iOs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆