测试已测试 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2014年12月 |
由 未申报 维护。
依赖 | |
AFNetworking | ~> 2.0.0 |
MACircleProgressIndicator | ~> 1.0.0 |
MACachedImageView
是一个用于从网络按需显示图像的 UIImageView
。它增加了缓存功能和美观的加载进度指示器。专门为 iOS 6 开发,但可能也适用于较旧的 iOS 版本。
如果您想不使用 CocoaPods 安装,克隆此存储库并将以下文件从 MACachedImageView
子文件夹复制到您的项目:
MACachedImageView.h
MACachedImageView.m
然后您必须手动将两个依赖库添加到您的项目中
MACachedImageView *cachedImageView = [MACachedImageView alloc] initWithFrame:CGRectMake(0,0,100,100)];
NSURL *url = [NSURL URLWithString:@"http://my.fancy.images.com/image.jpg"];
// Show an image by using the cache, if already available:
[cachedImageView displayImageFromURL:url];
// Show an image and force to refresh the cache:
[cachedImageView displayImageFromURL:url forceRefreshingCache:YES];
// Show a "local" UIImage:
UIImage *image = [UIImage imageNamed:@"image.jpg"];
[cachedImageView displayImage:image];
可以通过直接属性赋值或外观对象来自定义视图
MACachedImageView *appearance = [MACachedImageView appearance];
// Showing an image if no image is loaded yet or during loading an image:
appearance.placeholderImage = [UIImage imageNamed:@"..."];
// Use the placeholderImageContentMode property to decide how the placeholder
// image should be placed when shown.
appearance.placeholderImageContentMode = UIViewContentModeCenter;
// When displaying a loaded image, this content mode is used to show it properly.
appearance.imageContentMode = UIViewContentModeScaleAspectFill;
// The color of the download progress indicator.
appearance.progressIndicatorColor = [UIColor whiteColor];
// Set the stroke width of the MACircleProgressIndicator explicitly.
// progressIndicatorStrokeWidthRatio will be ignored.
//appearance.progressIndicatorStrokeWidth = 1.0;
// Set a ratio between the MACircleProgressIndicators size and the stroke width.
// progressIndicatorStrokeWidth will be ignored.
//appearance.progressIndicatorStrokeWidthRatio = 0.15; // default ratio, just for information :)
克隆此存储库并从命令行运行 pod install
以获取所有依赖项。打开生成的 workspace 文件。在 iPhone 或 iPad 模拟器中 运行
相关构建方案以启动示例应用。