Vij*_*jay 15 iphone objective-c uiimageview ios dynamic-image-generation
任何人都可以帮我,我希望水平多次添加相同的图像,高度和宽度相同.重要的是我正在动态创建图像视图我想为所有图像使用相同的图像视图!这是图像
我想像这样横向制作
但是这样只需要一行.
Nit*_*hel 16
这样使用Bellow方法stretchableImageWithLeftCapWidth就像这样使用: -
UIImage *backgroundImage = [[UIImage imageNamed:@"SheetBackground.png"] stretchableImageWithLeftCapWidth:0.5 topCapHeight:0];
Run Code Online (Sandbox Code Playgroud)
作为你需要的例子: -
UIImage *backgroundImage = [[UIImage imageNamed:@"q4Ses.png"] stretchableImageWithLeftCapWidth:0.5 topCapHeight:0];
[_scro setBackgroundColor:[UIColor colorWithPatternImage:backgroundImage]];
Run Code Online (Sandbox Code Playgroud)
并使用你的形象 
它的输出如下: -

![在此处输入图像说明] [4]
你可以设置图片为上述任何方式的UISCrollview,UIView,按钮比肩你需要不需要forloop为.
更新: -
如果您只想为一行添加上面的整个背景的上述代码,那么您必须创建一个UIview作为par你需要Hight并添加设置它colorWithPatternImage并添加像Bellow
UIImage *backgroundImage = [[UIImage imageNamed:@"q4Ses.png"]
stretchableImageWithLeftCapWidth:1 topCapHeight:0];
UIView *v=[[UIView alloc]
initWithFrame:CGRectMake(0, 0, _scro.frame.size.width, 45)];
[v setBackgroundColor:[UIColor
colorWithPatternImage:backgroundImage]];
[_scro addSubview:v];
Run Code Online (Sandbox Code Playgroud)
它的输出是: -
