@@ -15,24 +15,29 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
1515 fileprivate let arrowLayer = CAShapeLayer ( )
1616 fileprivate let textLabel = UILabel ( )
1717 fileprivate let strokeColor = UIColor ( red: 135.0 / 255.0 , green: 136.0 / 255.0 , blue: 137.0 / 255.0 , alpha: 1.0 )
18+ fileprivate let imageView = UIImageView ( frame: CGRect ( x: 0 , y: 0 , width: 230 , height: 35 ) )
19+
1820 override init ( frame: CGRect ) {
1921 super. init ( frame: frame)
2022 setUpCircleLayer ( )
2123 setUpArrowLayer ( )
22- textLabel. frame = CGRect ( x: 0 , y: 0 , width: 120 , height: 40 )
2324 textLabel. textAlignment = . center
2425 textLabel. textColor = UIColor . lightGray
2526 textLabel. font = UIFont . systemFont ( ofSize: 14 )
2627 textLabel. text = " 下拉即可刷新... "
27- let imageView = UIImageView ( frame: CGRect ( x: 0 , y: 0 , width: 230 , height: 35 ) )
2828 imageView. image = UIImage ( named: " taobaoLogo " )
2929 self . addSubview ( imageView)
3030 self . addSubview ( textLabel)
31+
32+ }
33+ override func layoutSubviews( ) {
34+ super. layoutSubviews ( )
3135 //放置Views和Layer
32- imageView. center = CGPoint ( x: frame. width/ 2 , y: frame. height - 60 - 18 )
33- textLabel. center = CGPoint ( x: frame. width/ 2 + 20 , y: frame. height - 30 )
34- self . arrowLayer. position = CGPoint ( x: frame. width/ 2 - 60 , y: frame. height - 30 )
35- self . circleLayer. position = CGPoint ( x: frame. width/ 2 - 60 , y: frame. height - 30 )
36+ textLabel. frame = CGRect ( x: 0 , y: 0 , width: 120 , height: 40 )
37+ imageView. center = CGPoint ( x: self . frame. width/ 2 , y: self . frame. height - 60 - 18 )
38+ textLabel. center = CGPoint ( x: self . frame. width/ 2 + 20 , y: self . frame. height - 30 )
39+ self . arrowLayer. position = CGPoint ( x: self . frame. width/ 2 - 60 , y: self . frame. height - 30 )
40+ self . circleLayer. position = CGPoint ( x: self . frame. width/ 2 - 60 , y: self . frame. height - 30 )
3641 }
3742 func setUpArrowLayer( ) {
3843 let bezierPath = UIBezierPath ( )
@@ -72,9 +77,18 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
7277 }
7378
7479// MARK: - RefreshableHeader -
75- func heightForRefreshingState ( ) -> CGFloat {
76- return 60
80+ func heightForHeader ( ) -> CGFloat {
81+ return 100
7782 }
83+
84+ func heightForFireRefreshing( ) -> CGFloat {
85+ return 60.0
86+ }
87+
88+ func heightForRefreshingState( ) -> CGFloat {
89+ return 60.0
90+ }
91+
7892 func percentUpdateDuringScrolling( _ percent: CGFloat ) {
7993 let adjustPercent = max ( min ( 1.0 , percent) , 0.0 )
8094 if adjustPercent == 1.0 {
@@ -84,6 +98,7 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
8498 }
8599 self . circleLayer. strokeEnd = 0.05 + 0.9 * adjustPercent
86100 }
101+
87102 func didBeginRefreshingState( ) {
88103 self . circleLayer. strokeEnd = 0.95
89104 let rotateAnimation = CABasicAnimation ( keyPath: " transform.rotation.z " )
@@ -95,19 +110,22 @@ class TaoBaoRefreshHeader:UIView,RefreshableHeader{
95110 self . arrowLayer. isHidden = true
96111 textLabel. text = " 刷新中... "
97112 }
113+
98114 func didBeginEndRefershingAnimation( _ result: RefreshResult ) {
99115 transitionWithOutAnimation {
100116 self . circleLayer. strokeEnd = 0.05
101117 } ;
102118 self . circleLayer. removeAllAnimations ( )
103119 }
120+
104121 func didCompleteEndRefershingAnimation( _ result: RefreshResult ) {
105122 transitionWithOutAnimation {
106123 self . circleLayer. strokeEnd = 0.05
107124 } ;
108125 self . arrowLayer. isHidden = false
109126 textLabel. text = " 下拉即可刷新 "
110127 }
128+
111129 func transitionWithOutAnimation( _ clousre: ( ) -> ( ) ) {
112130 CATransaction . begin ( )
113131 CATransaction . setDisableActions ( true )
0 commit comments