Skip to content

Commit

Permalink
Caching policy can be customized
Browse files Browse the repository at this point in the history
  • Loading branch information
EyreFree committed Jan 25, 2019
1 parent 0adbde9 commit 277e340
Show file tree
Hide file tree
Showing 8 changed files with 469 additions and 439 deletions.
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PODS:
- Kingfisher (4.10.1)
- WRCycleScrollView (0.1.0):
- Kingfisher (>= 4.10.0)
- WRCycleScrollView (0.1.0)
- WRNavigationBar_swift (0.1.0)

DEPENDENCIES:
- Kingfisher (= 4.10.1)
- WRCycleScrollView (from `../`)
- WRNavigationBar_swift (from `https://github.com/EFRenovation/WRNavigationBar_swift.git`)

Expand All @@ -25,9 +25,9 @@ CHECKOUT OPTIONS:

SPEC CHECKSUMS:
Kingfisher: c148cd7b47ebde9989f6bc7c27dcaa79d81279a0
WRCycleScrollView: d3d873ee075ca797056721d0286df967994df7f2
WRCycleScrollView: 06e6fa71feefcc0da9e23d75ec6133f4614e6ac8
WRNavigationBar_swift: b49ca280deb24616af40abae09d8ec593e75ac64

PODFILE CHECKSUM: 82eeaaada13c975b714571f2566f79f73d39841f
PODFILE CHECKSUM: 2b5278d7ddb14b20a3ab4b9bcbfff518c13499bf

COCOAPODS: 1.5.3
7 changes: 1 addition & 6 deletions Example/Pods/Local Podspecs/WRCycleScrollView.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

865 changes: 444 additions & 421 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Example/WRCycleScrollView/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import UIKit
import WRNavigationBar_swift
import Kingfisher
import WRCycleScrollView

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

setNavBarAppearence()

// 缓存器初始化
WRCycleScrollView.imageViewCacher = { [weak self] (imageView, url) in
guard let _ = self else { return }
imageView.kf.setImage(with: url)
}

return true
}

Expand Down
3 changes: 1 addition & 2 deletions WRCycleScrollView/Classes/WRCycleCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Github地址:https://github.com/wangrui460/WRCycleScrollView

import UIKit
import Kingfisher

public class WRCycleCell: UICollectionViewCell
{
Expand All @@ -19,7 +18,7 @@ public class WRCycleCell: UICollectionViewCell
didSet {
switch imgSource {
case let .SERVER(url):
imgView.kf.setImage(with: url)
WRCycleScrollView.imageViewCacher(imgView, url)
case let .LOCAL(name):
imgView.image = UIImage(named: name)
}
Expand Down
8 changes: 7 additions & 1 deletion WRCycleScrollView/Classes/WRCycleScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

import UIKit

public extension WRCycleScrollView {

/// 缓存器
public static var imageViewCacher: (UIImageView, URL) -> Void = { (imageView, url) in
fatalError("WRCycleScrollView.imageViewCacher must custom!")
}
}

@objc public protocol WRCycleScrollViewDelegate
{
Expand All @@ -20,7 +27,6 @@ import UIKit

public class WRCycleScrollView: UIView, PageControlAlimentProtocol, EndlessScrollProtocol
{

//=======================================================
// MARK: 对外提供的属性
//=======================================================
Expand Down

0 comments on commit 277e340

Please sign in to comment.