图画、图片显示
来源:互联网 发布:网络语言暴力公益广告 编辑:程序博客网 时间:2024/04/27 20:27
-(void)drawImageRect:(CGRect)rect
{
UIImage *image=[UIImage imageNamed:@"iphone.jpg"];
//原图片
CGImageRef imageRef=image.CGImage;
CGImageRef subImageRef=CGImageCreateWithImageInRect(imageRef, rect);
//原图中抠出来部分图
UIImage *subImage=[UIImage imageWithCGImage:subImageRef];
//新图
_imageView.image=subImage;
_imageView.frame=rect;
[UIView beginAnimations:nil context:nil];
//改变frame,改变过程中添加动画
[UIView setAnimationDuration:0.5];
_imageView.frame=CGRectMake(0, 20, rect.size.width, rect.size.height);
[UIView commitAnimations];
}
UIImage *image=[UIImage imageNamed:@"iphone.jpg"];
//原图片
CGImageRef imageRef=image.CGImage;
CGImageRef subImageRef=CGImageCreateWithImageInRect(imageRef, rect);
//原图中抠出来部分图
UIImage *subImage=[UIImage imageWithCGImage:subImageRef];
//新图
_imageView.image=subImage;
_imageView.frame=rect;
这几行代码是关键,将UIImage类型的image转化成CGImageRef类型的imageRef,然后根据imageRef和划出的区域取出画出的部分,再将这部分重新转化成UIImage类型。最后给UIImageView类型的_imageView显示出来。
- 图画、图片显示
- 图画
- Android图形图画学习(5)——解码图片
- 图画完了
- 绘制图画
- 图画段子
- iOS 使用百度地图地图画成功了,但是没有图层显示问题解决。
- Android 绘制手势路线制作图画板并把View保存为图片
- 图片显示
- 显示图片
- 图片显示
- 图片显示
- 图片显示
- 图片显示
- 显示图片
- 图片显示
- 显示图片
- 图片显示
- 南阳理工OJ_题目1036 非洲小孩
- 用myeclipse创建servlet
- 74LS112 实验 数字电路
- 数据结构与算法二
- Xilinx ZYNQ702C 双核无操作系统通讯配置
- 图画、图片显示
- CPU设计源代码(VHDL)
- 二会议室的飞洒发
- 编程与生活
- 照相机,短信、邮件、加速剂
- SQL Server服务器内存升级后的烦恼
- c# WINCE 使用技巧
- Nginx源码分析-内存池
- Terry七月Ruby读书笔记(比较详细)第2/4页