iOS开发常用的第三方类库
UIImage+Resize 调整图片大小
GitHub:https://github.com/coryalder/UIImage_Resize
提供多种方法为图片设置透明度、圆角、裁剪、调整大小等:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | - (UIImage *)imageWithAlpha; - (UIImage *)transparentBorderImage:(NSUInteger)borderSize; - (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize; - (UIImage *)croppedImage:(CGRect)bounds; - (UIImage *)thumbnailImage:(NSInteger)thumbnailSize transparentBorder:(NSUInteger)borderSize cornerRadius:(NSUInteger)cornerRadius interpolationQuality:(CGInterpolationQuality)quality; - (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality; - (UIImage *) resizedImageWithContentMode:(UIViewContentMode)contentMode bounds:(CGSize)bounds interpolationQuality:(CGInterpolationQuality)quality; |
更详细使用见:http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/
ImageCacheResize 异步加载图片、缓存及调整大小
GitHub:https://github.com/toptierlabs/ImageCacheResize
整合了SDWebImage和UIImage+Resize的功能,用于图片的异步加载、缓存、以及下载完成后调整大小并显示在UIImageView上。
提供了以下API用于加载图片以及加载完成后调整图片大小:
1 2 3 4 5 6 | - (void)setImageWithURL:(NSURL *)url andCropToBounds:(CGRect)bounds; - (void)setImageWithURL:(NSURL *)url andResize:(CGSize)size withContentMode:(UIViewContentMode)mode; - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder andCropToBounds:(CGRect)bounds; - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options andResize:(CGSize)size; - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options andResize:(CGSize)size withContentMode:(UIViewContentMode)mode; - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options andCropToBounds:(CGRect)bounds; |
使用方法和SDWebImage一样简单,如以下官方例子:
1 2 | [imageview setImageWithURL:[NSURL URLWithString:@http://t0.gstatic.com/images?q=tbn:ANd9GcQfraHpiabjEY8iDdBe9OUQYHMtwfuAv9ZRR0RYKuoVF_EpE8Fp5A] andResize:CGSizeMake(30, 30) withContentMode:UIViewContentModeScaleAspectFit]; // 按比例缩放 [imageview setImageWithURL:[NSURL URLWithString:@http://t0.gstatic.com/ima |
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)