我有图像(a),我希望它像(b)中的偏移一样重叠。但我最终得到了(c)
这段代码给了我(c)
UIImage * imgLeftBorder = [UIImage imageNamed:@"border_left"];
UIView * leftBorder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 25, screenHeight - 25)];
[leftBorder setBackgroundColor:[UIColor colorWithPatternImage:imgLeftBorder]];
[self.view addSubview:leftBorder];
我玩弄了偏移和插图,但我无法达到我的结果。有人做过这样的事吗?
答案 0 :(得分:0)
用一段时间怎么样?
int currY = 0;
while(currY < screenHeight) {
UIImageView *leftBorder = [[UIImageView alloc] initWithFrame:CGRectMake(0, currY, imgLeftBorder.size.width, imgLeftBorder.size.width)];
leftBorder.image = imgLeftBorder;
[self.view addSubview:leftBorder];
currY += imgLeftBorder.size.width - 25;
}