// // 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