UIkit框架之UIimage
1.继承链:NSObject
2.以下有三种方法来创建图片对象
(1) imageNamed:inBundle:compatibleWithTraitCollection:从image asset或者主要的捆绑包中载入图片来进行创建图片对象。
(2) imageWithContentsOfFile: or initWithContentsOfFile:从本地文件中载入图片进行创建图片对象
(3) animatedImageWithImages:duration: and animatedImageNamed:duration:可以创建一个包含多个图片的图片对象,一般是用来播放动画的
3.使用 UIImagePickerController可以让用户进入自己的相册选取照片
4. 使用resizableImageWithCapInsets: or resizableImageWithCapInsets:resizingMode:方法可以定义可伸展图片,可以改变图片的大小以适合容器的大小,让人看起来更加舒服

5.使用isequal方法可以判断两张图片是否相等,这是唯一的方法,使用==是错误的
UIImage* image1 = [UIImage imageNamed:@"MyImage"];UIImage* image2 = [UIImage imageNamed:@"MyImage"];// The image objects may be different, but the contents are still equalif ([image1 isEqual:image2]) {// Correct. This technique compares the image data correctly.}
6. 可以使用CGImage and CIImage属性来检索各种版本的图片
7.可以使用 UIImagePNGRepresentation and UIImageJPEGRepresentation功能来生成png或者JPEG格式的图片数据
8.可以使用的方法或者属性:
(1)+ (UIImage *)imageNamed:(NSString *)name
inBundle:(NSBundle *)bundle compatibleWithTraitCollection:(UITraitCollection *)traitCollection,name是在bundle中图片的名称,bundle是用来存储图片的捆绑包,traitcollection暂时还不知道是干嘛的,它里面是这样描述的:The traits associated with the intended environment for the image. Use this parameter to ensure that the correct variant of the image is loaded. If you specify nil, this method uses the traits associated with the main screen.
(2)[image imageWithData:(NSData *)data]通过指定的图片数据对象用来创建和返回一个图片对象
(3)+ (UIImage *)imageWithData:(NSData *)data scale:(CGFloat)scale 使用这个方法可以通过一个数据对象和比例创建和返回一个图片对象
(4)+ (UIImage *)imageWithCGImage:(CGImageRef)cgImage 返回一个指定的quartz image对象转变后的对象
(5)+ (UIImage *)imageWithCGImage:(CGImageRef)imageRef scale:(CGFloat)scale orientation:(UIImageOrientation)orientation 返回一个设定比例和方向的图片对象 ,cgImage是一个quartz image对象
(6)+ (UIImage *)imageWithCIImage:(CIImage *)ciImage 创建和返回一个core image对象转变后的图片对象 , core image对象是经过压缩封装的图片
(7)+ (UIImage *)imageWithCIImage:(CIImage *)ciImage scale:(CGFloat)scale orientation:(UIImageOrientation)orientation 返回一个把core image对象的比例和方向转变后的图片对象
(8)- (instancetype)initWithData:(NSData *)data scale:(CGFloat)scale 返回一个比例为scale且是data里面的图片对象
(9)+ (UIImage *)animatedImageNamed:(NSString *)name duration:(NSTimeInterval)duration 返回一个动态图片,并且设定了一定的时间
(10)+ (UIImage *)animatedImageWithImages:(NSArray<UIImage *> *)images duration:(NSTimeInterval)duration 返回一个图片对象,并且这个对象的内容由图片数组组成、还设定动画的时间
(11)+ (UIImage *)animatedResizableImageNamed:(NSString *)name capInsets:(UIEdgeInsets)capInsets duration:(NSTimeInterval)duration 返回的图片设定了边界距离属性和动画时间
(12)+ (UIImage *)animatedResizableImageNamed:(NSString *)name capInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode duration:(NSTimeInterval)duration 返回的对象设定了边界距离属性、内部重构属性(我也不知道这是什么鬼)和动画时间,
注意:这个方法一般应用在动画需要改变大小的情况,resizingMode默认的类型是UIImageResizingModeTile,动画改变时使用 UIImageResizingModeStretch属性
(13)- (UIImage *)imageWithRenderingMode:(UIImageRenderingMode)renderingMode 返回的对象经过renderingmode参数渲染
(14)- (UIImage *)imageWithAlignmentRectInsets:(UIEdgeInsets)alignmentInsets 返回的对象经过边界距离属性调整,如果你重新调整了按钮的大小,但是北京图片的coners不会改变并且大小会跟随按钮的变化而变化
(15)- (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode 只有当你想使用 UIImageResizingModeStretch方法来重构图片大小的时候你才可以调用这个方法
(16)- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight 会改变图片里面的中间的区域,大小为leftcapwidth*topcapheight
9.只读属性:size、scale、imageorientation、flipsforrighttoleftlayoutdirection、resizingmode、cgimage、ciimage、images、duration、capinset、alignmentrectinsets、imageasset、traitcollection
10.drawing images
(1)- (void)drawAtPoint:(CGPoint)point在当前的上下文中绘画图片到指定的点上
(2)
- (void)drawAtPoint:(CGPoint)point blendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha
Parameters
point |
The point at which to draw the top-left corner of the image. |
blendMode |
The blend mode to use when compositing the image. |
alpha |
The desired opacity of the image, specified as a value between 0.0 and 1.0. A value of 0.0 renders the image totally transparent while 1.0 renders it fully opaque. Values larger than 1.0 are interpreted as 1.0. |
rect 在当前的上下文中重新绘制整个图片的大小rect
blendMode:(CGBlendMode)blendMode
alpha:(CGFloat)alpha 在当前的上下文中重新绘制图片的大小、模式和透明度rect 在指定的矩形中使用Quartz pattern来拼凑图片UIImageRenderingMode:UIImageRenderingModeAutomatic, UIImageRenderingModeAlwaysOriginal, UIImageRenderingModeAlwaysTemplate,
UIkit框架之UIimage的更多相关文章
- iOS开发概述UIkit动力学,讲述UIKit的Dynamic特性,UIkit动力学是UIkit框架中模拟真实世界的一些特性。
转发:http://my.oschina.net/u/1378445/blog/335014 iOS UIKit动力学 Dynamics UIAttachmentBehavior 实现iMessage ...
- UIKit 框架之Bar、Controller
UIKit框架中有各种Bar,UITabBar.UINavigationBar.UIToolbar.Bar对应的就有一些Item,tabBarItem.navigationItem.toolbarIt ...
- UIKit框架使用总结--看看你掌握了多少
一.经常使用的,基本就是每次项目迭代都需要使用的 UIView.UILabel.UIImage.UIColor.UIFont.UIImageView.UITextField.UIButton. UIS ...
- Swift - 重写UIKit框架类的init初始化方法(以UITabBarController为例)
原来写了篇文章讲UITabBarController的用法,当时是从UIViewController跳转到UITabBarController页面,代码如下: 1 self.presentViewCo ...
- UIKit框架
在今后的应用程序构建中,会陆续使用各式各样的控件,因此UIKit框架的引入是必不可少的! 一.简介 UIKitk框架提供一系列的Class(类)来建立和管理iPhone OS应用程序的用户界面接口.应 ...
- iOS学习32之UIKit框架-可视化编程-XIB
1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...
- 基础框架Fundation和UIkit框架的定义和使用
Foundation 框架为所有应用程序提供基本的系统服务 您的应用程序以及 UIKit 和其他框架,都建立在 Foundation 框架的基础结构之上.Foundation 框架提供许多基本的对象类 ...
- iOS开发UIKit框架-可视化编程-XIB
1. Interface Builder 可视化编程 1> 概述 GUI : 图形用户界面(Graphical User Interface, 简称GUI, 又称图形化界面) 是指采用图形方式显 ...
- 79、iOS 的Cocoa框架、Foundation框架以及UIKit框架
Cocoa框架是iOS应用程序的基础 1. Cocoa是什么? Cocoa是 OS X和ios 操作系统的程序的运行环境. 是什么因素使一个程序成为Cocoa程序呢?不是编程语言,因为在Cocoa开发 ...
随机推荐
- Windows下安装并设置Redis
Redis对于Linux是官方支持的,安装和使用没有什么好说的,普通使用按照官方指导,5分钟以内就能搞定.详情请参考: http://redis.io/download 但有时候又想在windows下 ...
- HTML5自学笔记[ 23 ]canvas绘图基础7
变换矩阵: transform(a,b,c,d,e,f),多次使用该函数,效果是多次状态改变的累加: setTransform(a,b,c,d,e,f),会忽略之前的变换,从起始状态开始改变.
- 张艾迪(创始人):DCM的不识人.我说我会像乔布斯一样成为投资者的骄傲
Eidyzhang解码:天才Eidyzhang的诞生 张艾迪(创始人):第一个实习生精英团队 张艾迪(创始人):DCM的不识人.我说我会像乔布斯一样成为投资者的骄傲 2014-05-31 09:4 ...
- iOS项目的目录结构和开发流程
转自无网不剩的博客 网上相关的资源不多,开源的且质量还不错的iOS项目也是少之又少,最近正好跟同事合作了一个iOS项目,来说说自己的一些想法. 目录结构 AppDelegate Models Ma ...
- Redis(7)Creating and Using Cluster Mode
1. DocumentsCluster will not support SELECT, it only contains database 0.All the nodes use TCP bus a ...
- Firefox火狐Flash插件卡死问题完美解决方法(转载)
http://www.ihacksoft.com/firefox-flash-protectedmode.html 其实这个问题以前就出现过,而最近该问题又出现在最新的 Windows 8.1 系统中 ...
- MATLAB 矩阵转化为灰度图
A=[ 1.00 0.96 0.98 0.88 0.94 0.61 0.96 0.80 0.98 0.89 0.96 1.00 0.94 0.90 0.95 0.71 0.96 0.83 0.90 0 ...
- spring mvc读取url变量
@RequestMapping(value="/{id}/{name}", method=RequestMethod.GET) public ModelAndView getUrl ...
- HTML元素,属性,基础标签
元素,属性 元素 html有父元素和子元素,被包含的叫子元素,如html是head的父元素,他们是父子关系,head和body是兄弟关系 <html> <head></h ...
- TCP/IP 某些最常见的错误原因码 (errno)列表
对于在基于 UNIX 的环境中的 TCP/IP 用户,下表列出了某些最常见的错误原因码 (errno).它不是完整的错误列表.可以在文件 /usr/include/sys/errno.h 中找到 Er ...