Skip to content

Commit 277e340

Browse files
committed
Caching policy can be customized
1 parent 0adbde9 commit 277e340

File tree

8 files changed

+469
-439
lines changed

8 files changed

+469
-439
lines changed

Example/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
PODS:
22
- Kingfisher (4.10.1)
3-
- WRCycleScrollView (0.1.0):
4-
- Kingfisher (>= 4.10.0)
3+
- WRCycleScrollView (0.1.0)
54
- WRNavigationBar_swift (0.1.0)
65

76
DEPENDENCIES:
7+
- Kingfisher (= 4.10.1)
88
- WRCycleScrollView (from `../`)
99
- WRNavigationBar_swift (from `https://github.com/EFRenovation/WRNavigationBar_swift.git`)
1010

@@ -25,9 +25,9 @@ CHECKOUT OPTIONS:
2525

2626
SPEC CHECKSUMS:
2727
Kingfisher: c148cd7b47ebde9989f6bc7c27dcaa79d81279a0
28-
WRCycleScrollView: d3d873ee075ca797056721d0286df967994df7f2
28+
WRCycleScrollView: 06e6fa71feefcc0da9e23d75ec6133f4614e6ac8
2929
WRNavigationBar_swift: b49ca280deb24616af40abae09d8ec593e75ac64
3030

31-
PODFILE CHECKSUM: 82eeaaada13c975b714571f2566f79f73d39841f
31+
PODFILE CHECKSUM: 2b5278d7ddb14b20a3ab4b9bcbfff518c13499bf
3232

3333
COCOAPODS: 1.5.3

Example/Pods/Local Podspecs/WRCycleScrollView.podspec.json

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 444 additions & 421 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Target Support Files/WRCycleScrollView/WRCycleScrollView.xcconfig

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/WRCycleScrollView/AppDelegate.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import UIKit
1111
import WRNavigationBar_swift
12+
import Kingfisher
13+
import WRCycleScrollView
1214

1315
let MainNavBarColor = UIColor.init(red: 0/255.0, green: 175/255.0, blue: 240/255.0, alpha: 1)
1416
let kScreenWidth = UIScreen.main.bounds.width
@@ -34,6 +36,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate
3436

3537
setNavBarAppearence()
3638

39+
// 缓存器初始化
40+
WRCycleScrollView.imageViewCacher = { [weak self] (imageView, url) in
41+
guard let _ = self else { return }
42+
imageView.kf.setImage(with: url)
43+
}
44+
3745
return true
3846
}
3947

WRCycleScrollView/Classes/WRCycleCell.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// Github地址:https://github.com/wangrui460/WRCycleScrollView
99

1010
import UIKit
11-
import Kingfisher
1211

1312
public class WRCycleCell: UICollectionViewCell
1413
{
@@ -19,7 +18,7 @@ public class WRCycleCell: UICollectionViewCell
1918
didSet {
2019
switch imgSource {
2120
case let .SERVER(url):
22-
imgView.kf.setImage(with: url)
21+
WRCycleScrollView.imageViewCacher(imgView, url)
2322
case let .LOCAL(name):
2423
imgView.image = UIImage(named: name)
2524
}

WRCycleScrollView/Classes/WRCycleScrollView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
import UIKit
1111

12+
public extension WRCycleScrollView {
13+
14+
/// 缓存器
15+
public static var imageViewCacher: (UIImageView, URL) -> Void = { (imageView, url) in
16+
fatalError("WRCycleScrollView.imageViewCacher must custom!")
17+
}
18+
}
1219

1320
@objc public protocol WRCycleScrollViewDelegate
1421
{
@@ -20,7 +27,6 @@ import UIKit
2027

2128
public class WRCycleScrollView: UIView, PageControlAlimentProtocol, EndlessScrollProtocol
2229
{
23-
2430
//=======================================================
2531
// MARK: 对外提供的属性
2632
//=======================================================

0 commit comments

Comments
 (0)