跃迁引擎

空気を読んだ雨降らないでよ

iOS Research & Development


iOS 图像聚合加载视图 YCImageView 架构设计 & 使用

架构设计

执行设计

使用教程

Objective - C

使用 URL 加载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/// 常规使用
/// - Note: 不需要的回调直接传入 nil 即可
/// - Note: 注意,以下所有 回调内容 及 option 仅支持 PNG / JPG / JPEG / WebP / GIF 类型
UIImageView *imageView = (UIImageView *)[YCImageView yc_imageWithUrlString:@"xxxxx"
option:YCWebImageOptionNone
progress:^(NSInteger receivedSize, NSInteger expectedSize) {

} transform:^UIImage * _Nonnull(UIImage * _Nonnull image, NSURL * _Nonnull url) {
/// - Note: 在这里处理你的图片裁减等操作,将处理后的图像返回给 YCImageView
return image;
} completion:^(UIImage * _Nullable image, NSURL * _Nullable url, enum YCWebImageFromType fromType, enum YCWebImageStage stage, NSError * _Nullable error) {

}];

----------------------------------------------------------------------------------------

/// 需要手动接管 Lottie 动画时
LOTAnimationView *imageView = (LOTAnimationView *)[YCImageView yc_imageWithUrlString:@"xxxxx" option:YCWebImageOptionNone progress:nil transform:nil completion:nil];
/// - Note: 播放 Lottie
[imageView play];
/// - Note: 停止 Lottie
[imageView stop];

----------------------------------------------------------------------------------------

/// 需要手动接管 GIF 动画时
YYAnimatedImageView *imageView = (YYAnimatedImageView *)[YCImageView yc_imageWithUrlString:@"xxxxx" option:YCWebImageOptionNone progress:nil transform:nil completion:nil];
/// - Note: 播放 GIF
[imageView startAnimating];
/// - Note: 停止 GIF
[imageView stopAnimating];

使用资源名称加载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// - Note: 用法类似,需要指定资源类型 resourceType
UIImageView *imageView = (UIImageView *)[YCImageView yc_imageWithName:@"xxxx" resourceType:YCWebImageResourceTypePng];

/// - Note: 枚举类型
public enum YCWebImageResourceType: UInt {
/// PNG 图片类型
case png = 0
/// JPG 图片类型
case jpg = 1
/// JPEG 图片类型
case jpeg = 2
/// WebP 图片类型
case webp = 3
/// GIF 动图类型
case gif = 4
/// Lottie 动画 JSON 文件类型
case lottie = 5
/// SVG 类型
case svg = 6
}

Swift

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/// 常规用法,注意事项与 Objective-C 中标明的一致
let imageView: UIImageView = YCImageView.yc_image(urlString: "xxxx", option: .none, progress: nil, transform: nil, completion: nil) as UIImageView

----------------------------------------------------------------------------------------

/// 需要手动接管 Lottie 时
let imageView: LOTAnimationView = YCImageView.yc_image(urlString: "xxxx", option: .none, progress: nil, transform: nil, completion: nil) as LOTAnimationView
/// - Note: 播放 Lottie
imageView.play()
/// - Note: 停止 Lottie
imageView.stop()

----------------------------------------------------------------------------------------

/// 需要手动接管 GIF 时
let imageView: YYAnimatedImageView = YCImageView.yc_image(urlString: "xxxx", option: .none, progress: nil, transform: nil, completion: nil) as YYAnimatedImageView
/// - Note: 播放 GIF
imageView.startAnimating()
/// - Note: 停止 GIF
imageView.stopAnimating()
最近的文章

Rust 工程结构初探

Rust 项目的依赖管理机制 Rust 的依赖管理是基于项目的根 Cargo.toml 文件,而不是子目录中的 Cargo.toml 文件。如果再子目录的 Cargo.toml 文件中描述,即使同样在子目录中的.rs文件,也会出现识别不到的问题。 我们需要明确 Rust 项目的依赖管理机制。在 …

, , 开始阅读
更早的文章

字符串最短循环子串

问题问题描述小M在研究字符串时发现了一个有趣的现象:某些字符串是由一个较短的子串反复拼接而成的。如果能够找到这个最短的子串,便可以很好地还原字符串的结构。你的任务是给定一个字符串,判断它是否是由某个子串反复拼接而成的。如果是,输出该最短的子串;否则,输出空字符串""。 例如:当输 …

, , 开始阅读
comments powered by Disqus