码迷,mamicode.com
首页 > 其他好文 > 详细

UIImage

时间:2015-08-31 21:01:14      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:

1UIImage2种加载图片方式

(1)有缓存(图片所占用的内存会一直停留在程序中),可能会导致占用大量内存而使程序崩溃,加载少量小图片时候使用。

+ (UIImage *)imageNamed:(NSString *)name;

name是图片的文件名,png图片不用加后缀名,jpg等其他图片格式要加后缀名。

(2)无缓存(图片所占用的内存会在一些特定操作后被清除),在加载大量图片时候使用

+ (UIImage *)imageWithContentsOfFile:(NSString *)path

- (id)initWithContentsOfFile:(NSString *)path;

path是图片的全路径

例如:

NSBundle *bundle = [NSBundle mainBundle];

NSString *path = [bundle pathForResource:filename ofType:nil];

UIImage *image = [UIImage imageWithContentsOfFile:path];

2、设置UIImageVeiw圆角

self.iconView.layer.cornerRadius = 8;//圆角半径

self.iconView.clipsToBounds = YES;//超出圆角部分都减掉

【备注】UIImageView还可以设置高亮(被点击)图片:

myImageView.highlightedImage = ……………….

UIImage

标签:

原文地址:http://www.cnblogs.com/lifengfneg/p/4773811.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!