Skip to content

Commit 132d9e6

Browse files
committedMay 5, 2016
Add project commit
1 parent 5a23857 commit 132d9e6

File tree

19 files changed

+1752
-0
lines changed

19 files changed

+1752
-0
lines changed
 

‎ESPullToRefresh.podspec

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'pull-to-refresh'
3+
s.version = '1.0.0'
4+
s.summary = 'An easy way to use pull-to-refresh and loading-more.'
5+
s.homepage = 'https://github.com/eggswift/pull-to-refresh'
6+
s.license = 'MIT'
7+
s.authors = {'lihao' => 'lihao_ios@hotmail.com'}
8+
s.platform = :ios, '8.0'
9+
s.source = {:git => 'https://github.com/eggswift/pull-to-refresh.git', :tag => s.version}
10+
s.source_files = 'ESPullToRefresh/**/*.{h,m}'
11+
s.resource = ''
12+
s.requires_arc = true
13+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// ESRefreshFooterAnimator.swift
3+
//
4+
// Created by egg swift on 16/4/7.
5+
// Copyright (c) 2013-2015 ESPullToRefresh (https://github.com/eggswift/pull-to-refresh)
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
//
25+
26+
import UIKit
27+
28+
public class ESRefreshFooterAnimator: UIView, ESRefreshProtocol, ESRefreshAnimatorProtocol {
29+
private let titleLabel: UILabel = UILabel.init(frame: CGRect.zero)
30+
private let indicatorView: UIActivityIndicatorView = UIActivityIndicatorView.init(activityIndicatorStyle: .Gray)
31+
32+
public var animatorView: UIView {
33+
return self
34+
}
35+
36+
override init(frame: CGRect) {
37+
super.init(frame: frame)
38+
addSubview(titleLabel)
39+
addSubview(indicatorView)
40+
indicatorView.hidden = true
41+
titleLabel.font = UIFont.systemFontOfSize(14.0)
42+
titleLabel.textColor = UIColor.init(white: 160.0 / 255.0, alpha: 1.0)
43+
titleLabel.textAlignment = .Center
44+
titleLabel.frame = bounds
45+
titleLabel.text = "下拉加载"
46+
}
47+
48+
required public init(coder aDecoder: NSCoder) {
49+
fatalError("init(coder:) has not been implemented")
50+
}
51+
52+
public func refreshAnimationDidBegin(view: ESRefreshComponent) {
53+
indicatorView.startAnimating()
54+
indicatorView.hidden = false
55+
}
56+
57+
public func refreshAnimationDidEnd(view: ESRefreshComponent) {
58+
indicatorView.stopAnimating()
59+
indicatorView.hidden = true
60+
}
61+
62+
public func refresh(view: ESRefreshComponent, progressDidChange progress: CGFloat) {
63+
// do nothing
64+
}
65+
66+
public func refresh(view: ESRefreshComponent, stateDidChange state: ESRefreshViewState) {
67+
switch state {
68+
case .Loading:
69+
titleLabel.text = "加载中..."
70+
case .PullToRefresh:
71+
titleLabel.text = "下拉加载"
72+
case .ReleaseToRefresh:
73+
titleLabel.text = "下拉加载"
74+
case .NoMoreData:
75+
titleLabel.text = "暂无更多数据"
76+
}
77+
}
78+
79+
override public func layoutSubviews() {
80+
super.layoutSubviews()
81+
let s = self.bounds.size
82+
let w = s.width
83+
let h = s.height
84+
let s1 = titleLabel.sizeThatFits(self.bounds.size)
85+
titleLabel.frame = CGRect.init(x: (w - s1.width) / 2.0 + 8.0, y: (h - s1.height) / 2.0, width: s1.width, height: s1.height)
86+
indicatorView.center = CGPoint.init(x: titleLabel.frame.origin.x - 18.0, y: h / 2.0)
87+
}
88+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//
2+
// ESRefreshHeaderView.swift
3+
//
4+
// Created by egg swift on 16/4/7.
5+
// Copyright (c) 2013-2015 ESPullToRefresh (https://github.com/eggswift/pull-to-refresh)
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
//
25+
26+
import Foundation
27+
import QuartzCore
28+
import UIKit
29+
30+
public class ESRefreshHeaderAnimator: UIView, ESRefreshProtocol, ESRefreshAnimatorProtocol {
31+
private var imageView: UIImageView!
32+
33+
public var animatorInsets: UIEdgeInsets = UIEdgeInsetsZero
34+
35+
public var animatorView: UIView {
36+
return self
37+
}
38+
39+
override init(frame: CGRect) {
40+
super.init(frame: frame)
41+
self.clipsToBounds = true
42+
imageView = UIImageView.init()
43+
self.addSubview(imageView)
44+
}
45+
46+
required public init(coder aDecoder: NSCoder) {
47+
fatalError("init(coder:) has not been implemented")
48+
}
49+
50+
public func refreshAnimationDidBegin(view: ESRefreshComponent) {
51+
imageView.startAnimating()
52+
}
53+
54+
public func refreshAnimationDidEnd(view: ESRefreshComponent) {
55+
imageView.stopAnimating()
56+
}
57+
58+
public func refresh(view: ESRefreshComponent, progressDidChange progress: CGFloat) {
59+
let percent = max(0.0, min(1.0, progress * 1.2))
60+
let s = CGSize.init(width: 139 * 0.7, height: 110 * 0.7)
61+
let p = CGPoint.init(x: (self.bounds.size.width - s.width) / 2.0, y: (self.bounds.size.height / 2.0) * (1 + percent) - (s.height - 15 * 0.7) * percent)
62+
imageView.alpha = percent
63+
imageView.frame = CGRect.init(origin: p, size: s)
64+
}
65+
66+
public func refresh(view: ESRefreshComponent, stateDidChange state: ESRefreshViewState) {
67+
68+
}
69+
70+
}

0 commit comments

Comments
 (0)
Please sign in to comment.