Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added indicatorColor property to customize UIActivityIndicator color #212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = ESPullToRefresh/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.eggswift.ESPullToRefresh;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -497,7 +497,7 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = ESPullToRefresh/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.eggswift.ESPullToRefresh;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -627,7 +627,7 @@
CURRENT_PROJECT_VERSION = 2.9.2;
DEVELOPMENT_TEAM = A367N9R36B;
INFOPLIST_FILE = ESPullToRefreshExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.9.2;
PRODUCT_BUNDLE_IDENTIFIER = com.eggswift.ESPullToRefreshExample11;
Expand All @@ -645,7 +645,7 @@
CURRENT_PROJECT_VERSION = 2.9.2;
DEVELOPMENT_TEAM = A367N9R36B;
INFOPLIST_FILE = ESPullToRefreshExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.6;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.9.2;
PRODUCT_BUNDLE_IDENTIFIER = com.eggswift.ESPullToRefreshExample11;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,26 @@ public class ESRefreshTableViewController: UITableViewController {
break
}

self.tableView.es.addPullToRefresh(animator: header) { [weak self] in
self?.refresh()
}
self.tableView.es.addInfiniteScrolling(animator: footer) { [weak self] in
self?.loadMore()
if type == .defaultWithColor {
let header2 = ESRefreshHeaderAnimator.init(frame: CGRect.zero)
header2.indicatorColor = UIColor.red
self.tableView.es.addPullToRefresh(animator: header2) { [weak self] in
self?.refresh()
}
let footer2 = ESRefreshHeaderAnimator.init(frame: CGRect.zero)
footer2.indicatorColor = UIColor.green
self.tableView.es.addInfiniteScrolling(animator: footer2) { [weak self] in
self?.loadMore()
}
} else {
self.tableView.es.addPullToRefresh(animator: header) { [weak self] in
self?.refresh()
}
self.tableView.es.addInfiniteScrolling(animator: footer) { [weak self] in
self?.loadMore()
}
}

self.tableView.refreshIdentifier = String.init(describing: type)
self.tableView.expiredTimeInterval = 20.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum ESRefreshExampleType: String {
case textView = "TextView"
case day = "Day"
case collectionView = "CollectionView"
case defaultWithColor = "Default With Color"
}

public enum ESRefreshExampleListType {
Expand All @@ -32,7 +33,8 @@ public class ViewController: UIViewController, UITableViewDataSource, UITableVie
.wechat,
.textView,
.day,
.collectionView]
.collectionView,
.defaultWithColor]

public override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -72,6 +74,11 @@ public class ViewController: UIViewController, UITableViewDataSource, UITableVie
vc = ESRefreshTableViewController.init(style: .plain)
case .collectionView:
vc = CollectionViewController()
case .defaultWithColor:
vc = ESRefreshTableViewController.init(style: .plain)
if let vc = vc as? ESRefreshTableViewController {
vc.type = .defaultWithColor
}
}
vc.title = element.rawValue
self.navigationController?.pushViewController(vc, animated: true)
Expand Down
8 changes: 8 additions & 0 deletions Sources/Animator/ESRefreshFooterAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ open class ESRefreshFooterAnimator: UIView, ESRefreshProtocol, ESRefreshAnimator
return indicatorView
}()

open var indicatorColor: UIColor = .gray {
didSet {
if indicatorColor != oldValue {
indicatorView.color = indicatorColor
}
}
}

public override init(frame: CGRect) {
super.init(frame: frame)
titleLabel.text = loadingMoreDescription
Expand Down
8 changes: 8 additions & 0 deletions Sources/Animator/ESRefreshHeaderAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ open class ESRefreshHeaderAnimator: UIView, ESRefreshProtocol, ESRefreshAnimator
open var trigger: CGFloat = 60.0
open var executeIncremental: CGFloat = 60.0
open var state: ESRefreshViewState = .pullToRefresh

open var indicatorColor: UIColor = .gray {
didSet {
if indicatorColor != oldValue {
indicatorView.color = indicatorColor
}
}
}

fileprivate let imageView: UIImageView = {
let imageView = UIImageView.init()
Expand Down