iOS图片重复填充

有两种方式:
方式一:colorWithPatternImage用背景颜色设置图片

UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 400, 18)]; [self.view addSubview:imageView]; imageView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"ico_pk_bar_blue.png"]];

【iOS图片重复填充】方式二:UIImageResizingModeTileresize图片
UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 100, 400, 18)]; [self.view addSubview:imageView]; UIImage *image = [UIImage imageNamed:@"ico_pk_bar_blue.png"]; UIImage * newImage = [image resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeTile]; imageView.image = newImage;

    推荐阅读