把图片切割的方法
- (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();