``` -(UIImage*)drawImageAllInBgWithImage:(UIImage*)image Size:(CGSize)size{
//开启上下文
UIGraphicsBeginImageContextWithOptions(size, NO, 0);
CGFloat heightNum = size.height/image.size.height;
CGFloat widthNum = size.width/image.size.width;
for (int i=0; i<ceilf(heightNum); i++) {
for (int j=0; j<ceil(widthNum); j++) {
[image drawInRect:CGRectMake(j*image.size.width, i*image.size.height, image.size.width, image.size.height)];
}
}
//获取图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//关闭上下文
UIGraphicsEndImageContext();
return newImage;
}
网友评论