一:
- (void)drawRect:(CGRect)rect
{
CGContextRef
//设置倒立
CGContextRotateCTM(context,M_PI);
//重新设置坐标
CGContextTranslateCTM(context, -self.bounds.size.width,-self.bounds.size.height);
//CGContextScaleCTM(context, 1.0, -1.0);
CGRect
//画底图
CGContextDrawImage(context, imageRect,
//填充颜色
CGContextSetRGBStrokeCol
CGContextFillRect(context,self.bounds);
CGRect
//裁剪
CGContextClipToRect(context, ret);
//获取裁剪区域
CGRect
int
int
int
int
//画出裁剪区域
CGContextDrawImage(context,
}
二:
UIImage *image=[UIImage imageNamed:@"**.png"];
创建矩形
CGRect
根据矩形创建image
UIImageView.image=[UIImage imageWidthCGImage:CGImageCreateWidthImageI
将image添加到imageview中
显示view
参考:
NSLog(@"image
UIImageView
imgview.frame
CGRect
CGImageRef
imgview.image
CGImageRelease(cgimg);//用完一定要释放,否则内存泄露
[self.view