SkillAgentSearch skills...

MJRefresh

An easy way to use pull-to-refresh.

Install / Use

/learn @CoderMJLee/MJRefresh
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

MJRefresh

SPM supported Carthage compatible podversion

  • An easy way to use pull-to-refresh

📜✍🏻Release Notes: more details

Contents

New Features

<a id="SupportFlipsInCollectionViewLayout"></a>Support Flips In CollectionViewLayout

Refer to issue #1616.

  • Use additionalFlipsViews to append views that need to flip when collectionViewLayout flipsHorizontallyInOppositeLayoutDirection is true.
  • Use flipsHorizontallyInOppositeLayoutDirectionViews to modify views as the same way above. ⚠️ BUT parent class may be affected. Use additionalFlipsViews instead.

<a id="dynamic_i18n_switching"></a>Dynamic i18n Switching

Now MJRefresh components will be rerendered automatically with MJRefreshConfig.default.language setting.

Example

Go i18n folder and see lots of cases. Simulator example is behind i18n tab in right-top corner.

Setting language

MJRefreshConfig.default.language = "zh-hans"

Setting i18n file name

MJRefreshConfig.default.i18nFilename = "i18n File Name(not include type<.strings>)"

Setting i18n language bundle

MJRefreshConfig.default.i18nBundle = <i18n Bundle>

Adopting the feature in your DIY component

  1. Just override i18nDidChange function and reset texts.
// must use this localization methods
Bundle.mj_localizedString(forKey: "")
// or
Bundle.mj_localizedString(forKey: "", value:"")

override func i18nDidChange() {
    // Reset texts function
    setupTexts()
    // Make sure to call super after resetting texts. It will call placeSubViews for applying new layout.
    super.i18nDidChange()
}
  1. Receiving MJRefreshDidChangeLanguageNotification notification.

<a id="spm_supported"></a>SPM Supported

Released from 3.7.1

<a id="swift_chaining_grammar_supported"></a>Swift Chaining Grammar Supported

  // Example as MJRefreshNormalHeader
  func addRefreshHeader() {
      MJRefreshNormalHeader { [weak self] in
  	  // load some data
      }.autoChangeTransparency(true)
      .link(to: tableView)
  }

<a id="Support_what_kinds_of_controls_to_refresh"></a>Support what kinds of controls to refresh

  • UIScrollViewUITableViewUICollectionViewWKWebView

<a id="How_to_use_MJRefresh"></a>How to use MJRefresh

  • Installation with CocoaPods:pod 'MJRefresh'
  • Installation with Carthagegithub "CoderMJLee/MJRefresh"
  • Manual import:
    • Drag All files in the MJRefresh folder to project
    • Import the main file:#import "MJRefresh.h"
Base                        Custom
MJRefresh.bundle            MJRefresh.h
MJRefreshConst.h            MJRefreshConst.m
UIScrollView+MJExtension.h  UIScrollView+MJExtension.m
UIScrollView+MJRefresh.h    UIScrollView+MJRefresh.m
UIView+MJExtension.h        UIView+MJExtension.m

<a id="More_than_hundreds_of_Apps_are_using_MJRefresh"></a>More than hundreds of Apps are using MJRefresh

<img src="http://images0.cnblogs.com/blog2015/497279/201506/141212365041650.png" width="200" height="300"> * More information of App can focus on:[M了个J-博客园](http://www.cnblogs.com/mjios/p/4409853.html)

<a id="The_Class_Structure_Chart_of_MJRefresh"></a>The Class Structure Chart of MJRefresh

  • The class of red text in the chart:You can use them directly

    • The drop-down refresh control types
      • Normal:MJRefreshNormalHeader
      • Gif:MJRefreshGifHeader
    • The pull to refresh control types
      • Auto refresh
        • Normal:MJRefreshAutoNormalFooter
        • Gif:MJRefreshAutoGifFooter
      • Auto Back
        • Normal:MJRefreshBackNormalFooter
        • Gif:MJRefreshBackGifFooter
  • The class of non-red text in the chart:For inheritance,to use DIY the control of refresh

  • About how to DIY the control of refresh,You can refer the Class in below Chart<br>

    <img src="http://images0.cnblogs.com/blog2015/497279/201506/141358159107893.png" width="30%" height="30%">

<a id="MJRefreshComponent.h"></a>MJRefreshComponent.h

/** The Base Class of refresh control */
@interface MJRefreshComponent : UIView
#pragma mark -  Control the state of Refresh 

/** BeginRefreshing */
- (void)beginRefreshing;
/** EndRefreshing */
- (void)endRefreshing; 
/** IsRefreshing */
- (BOOL)isRefreshing;

#pragma mark - Other
/** According to the drag ratio to change alpha automatically */
@property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha;
@end

<a id="MJRefreshHeader.h"></a>MJRefreshHeader.h

@interface MJRefreshHeader : MJRefreshComponent
/** create header */
+ (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock;
/** create header */
+ (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action;

/** This key is used to storage the time that the last time of drown-down successfully */
@property (copy, nonatomic) NSString *lastUpdatedTimeKey;
/** The last time of drown-down successfully */
@property (strong, nonatomic, readonly) NSDate *lastUpdatedTime;

/** Ignored scrollView contentInset top */
@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop;
@end

<a id="MJRefreshFooter.h"></a>MJRefreshFooter.h

@interface MJRefreshFooter : MJRefreshComponent
/** create footer */
+ (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock;
/** create footer */
+ (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action;

/** NoticeNoMoreData */
- (void)noticeNoMoreData;
/** ResetNoMoreData(Clear the status of NoMoreData ) */
- (void)resetNoMoreData;

/** Ignored scrollView contentInset bottom */
@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom;
@end

<a id="MJRefreshAutoFooter.h"></a>MJRefreshAutoFooter.h

@interface MJRefreshAutoFooter : MJRefreshFooter
/** Is Automatically Refresh(Default is Yes) */
@property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh;

/** When there is much at the bottom of the control is automatically refresh(Default is 1.0,Is at the bottom of the control appears in full, will refresh automatically) */
@property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent;
@end

<a id="MJRefreshTrailer.h"></a> MJRefreshTrailer.h

@interface MJRefreshTrailer : MJRefreshComponent

/** 创建trailer */
+ (instancetype)trailerWithRefreshingBlock:(MJRefreshComponentAction)refreshingBlock
View on GitHub
GitHub Stars13.8k
CategoryDevelopment
Updated18h ago
Forks3.5k

Languages

Objective-C

Security Score

100/100

Audited on Mar 27, 2026

No findings