您的位置:首页 > 其它

把图片切割的方法

2015-09-25 23:41 525 查看
- (UIImage *)clipImage: (UIImage *)image inRect: (CGRect) rect
{
//返回image中rect范围内的图片
CGImageRef imageRef = CGImageCreateWithImageInRect(image.CGImage, rect);
UIImage *subImage = [UIImage imageWithCGImage:imageRef];
return subImage;
}

iv.image = [self clipImage:[UIImage imageNamed:@"king2"] inRect:CGRectMake(100*(i%3), 100*(i/3), 100, 100)];

DataStore *ds=[DataStore detectDataStore];

cell.textLabel.text=[ds.detectItems[indexPath.section][indexPath.row]myname];
cell.imageView.image=[ds.detectItems[indexPath.section][indexPath.row]img];
// cell.detailTextLabel.text=[ds.allItems[indexPath.section][indexPath.row]mydetailText];

CGSize itemSize = CGSizeMake(30, 30);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: