# XGPullup-and-down-the-refresh **Repository Path**: xiao66guo/XGPullup-and-down-the-refresh ## Basic Information - **Project Name**: XGPullup-and-down-the-refresh - **Description**: 完全自定义的上下拉刷新整体源码,只需导入一个头文件即可使用 - **Primary Language**: Objective-C - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 9 - **Forks**: 0 - **Created**: 2016-09-30 - **Last Updated**: 2025-07-28 ## Categories & Tags **Categories**: ios-modules **Tags**: None ## README #XGPullup-and-down-the-refresh 项目简介: 1️⃣用完全自定的方式来实现上拉加载更多、下拉刷新的功能; 2️⃣对上拉加载更多和下拉刷新功能已各自单独分离,可以单独使用; 3️⃣用Runtime运行时机制来监听刷新的状态; 4️⃣对细节的处理:用一个没有大小的FootView来把刷新控件的后面的分割线去掉; 5️⃣利用KVO来监听ScrollView滚动的位置来改变刷新控件的一个状态; 为ScollView添加的分类的相关代码: ``` // // UIScrollView+XGRefresh.m // XGRefresh // // Created by 小果 on 16/9/28. // Copyright © 2016年 小果. All rights reserved. // #import "UIScrollView+XGRefresh.h" #import static const char *upRefreshKey = "upRefreshKey"; static const char *downRefreshKey = "downRefreshKey"; @implementation UIScrollView (XGRefresh) -(void)setUpRefreshView:(XGPullupRefreshView *)upRefreshView{ objc_setAssociatedObject(self, upRefreshKey, upRefreshView, 1); } -(XGPullupRefreshView *)upRefreshView{ XGPullupRefreshView *upRefreshView = objc_getAssociatedObject(self, upRefreshKey); if (nil == upRefreshView) { upRefreshView = [[XGPullupRefreshView alloc] init]; [self addSubview:upRefreshView]; self.upRefreshView = upRefreshView; } return upRefreshView; } -(void)setDownRefreshView:(XGPullDownRefreshView *)downRefreshView{ objc_setAssociatedObject(self, downRefreshKey, downRefreshView, 1); } -(XGPullDownRefreshView *)downRefreshView{ XGPullDownRefreshView *downRefreshView = objc_getAssociatedObject(self, downRefreshKey); if (nil == downRefreshView) { downRefreshView = [[XGPullDownRefreshView alloc] init]; [self addSubview:downRefreshView]; self.downRefreshView = downRefreshView; } return downRefreshView; } @end ```