1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// KWMLoadingHeader.m
// iCemarose
//
// Created by HouWeiBin on 2017/1/24.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMLoadingHeader.h"
#import "KWMSuperLoadingView.h"
@interface KWMLoadingHeader()
@property (weak, nonatomic) KWMSuperLoadingView *loading;
@end
@implementation KWMLoadingHeader
#pragma mark - 重写方法
#pragma mark 在这里做一些初始化配置(比如添加子控件)
- (void)prepare
{
[super prepare];
// 设置控件的高度
self.mj_h = 50;
KWMSuperLoadingView *loading = [[KWMSuperLoadingView alloc] init];
self.loading = loading;
[self addSubview:loading];
[self.loading initLoadingView];
}
#pragma mark 在这里设置子控件的位置和尺寸
- (void)placeSubviews
{
[super placeSubviews];
self.loading.center = CGPointMake(self.mj_w/2 , self.mj_h * 0.5);
}
#pragma mark 监听scrollView的contentOffset改变
- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change
{
[super scrollViewContentOffsetDidChange:change];
}
#pragma mark 监听scrollView的contentSize改变
- (void)scrollViewContentSizeDidChange:(NSDictionary *)change
{
[super scrollViewContentSizeDidChange:change];
}
#pragma mark 监听scrollView的拖拽状态改变
- (void)scrollViewPanStateDidChange:(NSDictionary *)change
{
[super scrollViewPanStateDidChange:change];
}
#pragma mark 监听控件的刷新状态
- (void)setState:(MJRefreshState)state
{
MJRefreshCheckState;
switch (state) {
case MJRefreshStateIdle:
[self.loading setProgress:0];
break;
case MJRefreshStatePulling:
[self.loading setProgress:1];
break;
case MJRefreshStateRefreshing:
[self.loading startAnimation];
break;
default:
break;
}
}
#pragma mark 监听拖拽比例(控件被拖出来的比例)
- (void)setPullingPercent:(CGFloat)pullingPercent
{
[super setPullingPercent:pullingPercent];
[self.loading setProgress:pullingPercent];
}
@end