├── .swift-version ├── WYNullView ├── Images │ └── nullTest.gif ├── WYNullView.bundle │ ├── null_img@2x.png │ ├── null_img@3x.png │ ├── en.lproj │ │ └── Root.strings │ ├── ClassWhitelist.plist │ └── Root.plist ├── View │ ├── LoadingView.h │ ├── NullView.h │ ├── NSBundle+WY.h │ ├── NSBundle+WY.m │ ├── NullView.m │ └── LoadingView.m ├── WYNullView.h ├── Tool │ ├── WYWeakObject.m │ ├── WYWeakObject.h │ ├── GlobleNullViewRef.h │ └── GlobleNullViewRef.m └── Category │ ├── UIView+HiddenEx.h │ ├── UIView+WYNullView.h │ ├── UIView+HiddenEx.m │ └── UIView+WYNullView.m ├── Example └── WYNullViewDemo │ ├── WYNullViewDemo │ ├── Assets.xcassets │ │ ├── Contents.json │ │ └── AppIcon.appiconset │ │ │ ├── AppIcon-40x40@2x.png │ │ │ ├── AppIcon-40x40@3x.png │ │ │ ├── AppIcon-60x60@2x.png │ │ │ ├── AppIcon-60x60@3x.png │ │ │ └── Contents.json │ ├── ViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── NSString+TextHeight.h │ ├── NSString+TextHeight.m │ ├── Info.plist │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── AppDelegate.m │ └── ViewController.m │ ├── Pods │ ├── MJRefresh │ │ ├── MJRefresh │ │ │ ├── MJRefresh.bundle │ │ │ │ ├── arrow@2x.png │ │ │ │ ├── en.lproj │ │ │ │ │ └── Localizable.strings │ │ │ │ ├── zh-Hans.lproj │ │ │ │ │ └── Localizable.strings │ │ │ │ └── zh-Hant.lproj │ │ │ │ │ └── Localizable.strings │ │ │ ├── Base │ │ │ │ ├── MJRefreshBackFooter.h │ │ │ │ ├── MJRefreshAutoFooter.h │ │ │ │ ├── MJRefreshHeader.h │ │ │ │ ├── MJRefreshFooter.h │ │ │ │ ├── MJRefreshFooter.m │ │ │ │ ├── MJRefreshComponent.h │ │ │ │ ├── MJRefreshAutoFooter.m │ │ │ │ ├── MJRefreshHeader.m │ │ │ │ ├── MJRefreshBackFooter.m │ │ │ │ └── MJRefreshComponent.m │ │ │ ├── Custom │ │ │ │ ├── Footer │ │ │ │ │ ├── Auto │ │ │ │ │ │ ├── MJRefreshAutoNormalFooter.h │ │ │ │ │ │ ├── MJRefreshAutoGifFooter.h │ │ │ │ │ │ ├── MJRefreshAutoStateFooter.h │ │ │ │ │ │ ├── MJRefreshAutoNormalFooter.m │ │ │ │ │ │ ├── MJRefreshAutoStateFooter.m │ │ │ │ │ │ └── MJRefreshAutoGifFooter.m │ │ │ │ │ └── Back │ │ │ │ │ │ ├── MJRefreshBackNormalFooter.h │ │ │ │ │ │ ├── MJRefreshBackGifFooter.h │ │ │ │ │ │ ├── MJRefreshBackStateFooter.h │ │ │ │ │ │ ├── MJRefreshBackStateFooter.m │ │ │ │ │ │ ├── MJRefreshBackGifFooter.m │ │ │ │ │ │ └── MJRefreshBackNormalFooter.m │ │ │ │ └── Header │ │ │ │ │ ├── MJRefreshNormalHeader.h │ │ │ │ │ ├── MJRefreshGifHeader.h │ │ │ │ │ ├── MJRefreshStateHeader.h │ │ │ │ │ ├── MJRefreshGifHeader.m │ │ │ │ │ ├── MJRefreshNormalHeader.m │ │ │ │ │ └── MJRefreshStateHeader.m │ │ │ ├── NSBundle+MJRefresh.h │ │ │ ├── MJRefresh.h │ │ │ ├── UIView+MJExtension.h │ │ │ ├── UIScrollView+MJExtension.h │ │ │ ├── UIScrollView+MJRefresh.h │ │ │ ├── UIView+MJExtension.m │ │ │ ├── MJRefreshConst.m │ │ │ ├── NSBundle+MJRefresh.m │ │ │ ├── MJRefreshConst.h │ │ │ ├── UIScrollView+MJExtension.m │ │ │ └── UIScrollView+MJRefresh.m │ │ ├── LICENSE │ │ └── README.md │ ├── Target Support Files │ │ ├── MJRefresh │ │ │ ├── MJRefresh.modulemap │ │ │ ├── MJRefresh-dummy.m │ │ │ ├── MJRefresh-prefix.pch │ │ │ ├── MJRefresh.xcconfig │ │ │ ├── Info.plist │ │ │ └── MJRefresh-umbrella.h │ │ ├── WYNullView │ │ │ ├── WYNullView.modulemap │ │ │ ├── WYNullView-dummy.m │ │ │ ├── WYNullView-prefix.pch │ │ │ ├── WYNullView.xcconfig │ │ │ ├── WYNullView-umbrella.h │ │ │ └── Info.plist │ │ └── Pods-WYNullViewDemo │ │ │ ├── Pods-WYNullViewDemo.modulemap │ │ │ ├── Pods-WYNullViewDemo-dummy.m │ │ │ ├── Pods-WYNullViewDemo-umbrella.h │ │ │ ├── Pods-WYNullViewDemo.debug.xcconfig │ │ │ ├── Pods-WYNullViewDemo.release.xcconfig │ │ │ ├── Info.plist │ │ │ ├── Pods-WYNullViewDemo-acknowledgements.markdown │ │ │ ├── Pods-WYNullViewDemo-acknowledgements.plist │ │ │ ├── Pods-WYNullViewDemo-frameworks.sh │ │ │ └── Pods-WYNullViewDemo-resources.sh │ ├── Manifest.lock │ └── Local Podspecs │ │ └── WYNullView.podspec.json │ ├── WYNullViewDemo.xcworkspace │ └── contents.xcworkspacedata │ ├── Podfile │ ├── Podfile.lock │ ├── WYNullViewDemoTests │ ├── Info.plist │ └── WYNullViewDemoTests.m │ └── WYNullViewDemoUITests │ ├── Info.plist │ └── WYNullViewDemoUITests.m ├── LICENSE ├── README.md └── WYNullView.podspec /.swift-version: -------------------------------------------------------------------------------- 1 | 2.3 2 | -------------------------------------------------------------------------------- /WYNullView/Images/nullTest.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/WYNullView/Images/nullTest.gif -------------------------------------------------------------------------------- /WYNullView/WYNullView.bundle/null_img@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/WYNullView/WYNullView.bundle/null_img@2x.png -------------------------------------------------------------------------------- /WYNullView/WYNullView.bundle/null_img@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/WYNullView/WYNullView.bundle/null_img@3x.png -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /WYNullView/WYNullView.bundle/en.lproj/Root.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/WYNullView/WYNullView.bundle/en.lproj/Root.strings -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/MJRefresh/MJRefresh.modulemap: -------------------------------------------------------------------------------- 1 | framework module MJRefresh { 2 | umbrella header "MJRefresh-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/MJRefresh/MJRefresh-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_MJRefresh : NSObject 3 | @end 4 | @implementation PodsDummy_MJRefresh 5 | @end 6 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/WYNullView/WYNullView.modulemap: -------------------------------------------------------------------------------- 1 | framework module WYNullView { 2 | umbrella header "WYNullView-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/WYNullView/WYNullView-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_WYNullView : NSObject 3 | @end 4 | @implementation PodsDummy_WYNullView 5 | @end 6 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WymanLyu/WYNullView/HEAD/Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hans.lproj/Localizable.strings -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_WYNullViewDemo { 2 | umbrella header "Pods-WYNullViewDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_WYNullViewDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_WYNullViewDemo 5 | @end 6 | -------------------------------------------------------------------------------- /WYNullView/WYNullView.bundle/ClassWhitelist.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | MJRefreshHeader 6 | NullView 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/MJRefresh/MJRefresh-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/WYNullView/WYNullView-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshBackFooter : MJRefreshFooter 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /WYNullView/View/LoadingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LoadingView.h 3 | // HeiPa 4 | // 5 | // Created by wyman on 2017/3/14. 6 | // Copyright © 2017年 tykj. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define LOADING_WIDTH 50 12 | #define LOADING_HEIGHT 50 13 | 14 | @interface LoadingView : UIView 15 | 16 | - (void)startLoading; 17 | - (void)stopLoading; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'WYNullViewDemo' do 5 | # Uncomment the next line if you're using Swift or would like to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for WYNullViewDemo 9 | pod 'MJRefresh', '~> 3.1.1' 10 | pod 'WYNullView',:path => '../../' 11 | 12 | end 13 | -------------------------------------------------------------------------------- /WYNullView/WYNullView.h: -------------------------------------------------------------------------------- 1 | // 2 | // WYNullView.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/30. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | // 空视图、加载视图 10 | #import "UIView+WYNullView.h" 11 | #import "NullView.h" 12 | #import "LoadingView.h" 13 | 14 | // 附属工具 15 | #import "UIView+HiddenEx.h" 16 | #import "NSBundle+WY.h" 17 | #import "WYWeakObject.h" 18 | 19 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WYNullView/View/NullView.h: -------------------------------------------------------------------------------- 1 | // 2 | // NullView.h 3 | // HeiPa 4 | // 5 | // Created by wyman on 2017/3/14. 6 | // Copyright © 2017年 tykj. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define NULL_WIDTH 90 12 | #define NULL_HEIGHT 200 13 | 14 | @interface NullView : UIView 15 | 16 | @property (nonatomic, copy) NSString *nullIconImageName; 17 | 18 | @property (nonatomic, copy) NSString *desText; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /WYNullView/View/NSBundle+WY.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+WY.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/30. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface NSBundle (WY) 13 | 14 | + (instancetype)wy_nullViewBundle; 15 | 16 | + (UIImage *)wy_nullViewImage; 17 | 18 | + (NSMutableArray *)wy_classWhitelistArrayM; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/NSString+TextHeight.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+TextHeight.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface NSString (TextHeight) 13 | 14 | /** 给定最大宽度和字号 返回实际高度 */ 15 | - (CGFloat)wy_getHeightWithMaxWidth:(CGFloat)maxWidth font:(UIFont *)font; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_WYNullViewDemoVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_WYNullViewDemoVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /WYNullView/Tool/WYWeakObject.m: -------------------------------------------------------------------------------- 1 | // 2 | // WYWeakObject.m 3 | // 12-12WYEvent 4 | // 5 | // Created by wyman on 2017/2/10. 6 | // Copyright © 2017年 tykj. All rights reserved. 7 | // 8 | 9 | #import "WYWeakObject.h" 10 | 11 | extern WeakReference makeWeakReference(id object) { 12 | __weak id weakref = object; 13 | return ^{ 14 | return weakref; 15 | }; 16 | } 17 | 18 | extern id weakReferenceNonretainedObjectValue(WeakReference ref) { 19 | return ref ? ref() : nil; 20 | } 21 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter 12 | /** 菊花的样式 */ 13 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 14 | @end 15 | -------------------------------------------------------------------------------- /WYNullView/Tool/WYWeakObject.h: -------------------------------------------------------------------------------- 1 | // 2 | // WYWeakObject.h 3 | // 12-12WYEvent 4 | // 5 | // Created by wyman on 2017/2/10. 6 | // Copyright © 2017年 tykj. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef id (^WeakReference)(void); 12 | 13 | /** 14 | * 给定对象进行装箱,返回装箱后的弱引用对象 15 | */ 16 | extern WeakReference makeWeakReference(id object); 17 | /** 18 | * 给定弱引用对象进行解包,返回解包后的对象 19 | */ 20 | extern id weakReferenceNonretainedObjectValue(WeakReference ref); 21 | 22 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/NSBundle+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+MJRefresh.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 16/6/13. 6 | // Copyright © 2016年 小码哥. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSBundle (MJRefresh) 12 | + (instancetype)mj_refreshBundle; 13 | + (UIImage *)mj_arrowImage; 14 | + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value; 15 | + (NSString *)mj_localizedStringForKey:(NSString *)key; 16 | @end 17 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshNormalHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /WYNullView/Tool/GlobleNullViewRef.h: -------------------------------------------------------------------------------- 1 | // 2 | // GlobleNullViewRef.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @class NullView; 13 | typedef UIView *(^NullViewHandle)(NullView *defaultNullView); 14 | 15 | @interface GlobleNullViewRef : NSObject 16 | 17 | @property (nonatomic, copy) NullViewHandle globleNullViewHandle; 18 | 19 | + (instancetype)shareGlobleNullViewRef; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *arrowView; 13 | /** 菊花的样式 */ 14 | @property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; 15 | @end 16 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/MJRefresh/MJRefresh.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/MJRefresh 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/MJRefresh 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/WYNullView/WYNullView.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/WYNullView 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../../.. 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /WYNullView/Category/UIView+HiddenEx.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HiddenEx.h 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WYWeakObject.h" 11 | 12 | @interface UIView (HiddenEx) 13 | 14 | @property (nonatomic, strong) NSMutableArray *wy_classWhitelist; 15 | @property (nonatomic, strong) NSMutableArray *wy_objWhitelist; 16 | 17 | - (void)wy_hideOtherViewAndShowView:(UIView *)view; 18 | - (void)wy_showOtherViewAndHideView:(UIView *)view; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | 4 | #import "UIScrollView+MJRefresh.h" 5 | #import "UIScrollView+MJExtension.h" 6 | #import "UIView+MJExtension.h" 7 | 8 | #import "MJRefreshNormalHeader.h" 9 | #import "MJRefreshGifHeader.h" 10 | 11 | #import "MJRefreshBackNormalFooter.h" 12 | #import "MJRefreshBackGifFooter.h" 13 | #import "MJRefreshAutoNormalFooter.h" 14 | #import "MJRefreshAutoGifFooter.h" -------------------------------------------------------------------------------- /WYNullView/Tool/GlobleNullViewRef.m: -------------------------------------------------------------------------------- 1 | // 2 | // GlobleNullViewRef.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "GlobleNullViewRef.h" 10 | 11 | @implementation GlobleNullViewRef 12 | 13 | static GlobleNullViewRef *_nullViewRef = nil; 14 | 15 | + (instancetype)shareGlobleNullViewRef { 16 | if (nil == _nullViewRef) { 17 | static dispatch_once_t onceToken; 18 | dispatch_once(&onceToken, ^{ 19 | _nullViewRef = [GlobleNullViewRef new]; 20 | }); 21 | } 22 | return _nullViewRef; 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshGifHeader : MJRefreshStateHeader 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter : MJRefreshBackStateFooter 12 | @property (weak, nonatomic, readonly) UIImageView *gifView; 13 | 14 | /** 设置state状态下的动画图片images 动画持续时间duration*/ 15 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; 16 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state; 17 | @end 18 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/WYNullView/WYNullView-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "WYNullView.h" 14 | #import "UIView+HiddenEx.h" 15 | #import "UIView+WYNullView.h" 16 | #import "GlobleNullViewRef.h" 17 | #import "WYWeakObject.h" 18 | #import "LoadingView.h" 19 | #import "NSBundle+WY.h" 20 | #import "NullView.h" 21 | 22 | FOUNDATION_EXPORT double WYNullViewVersionNumber; 23 | FOUNDATION_EXPORT const unsigned char WYNullViewVersionString[]; 24 | 25 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter : MJRefreshBackFooter 12 | /** 文字距离圈圈、箭头的距离 */ 13 | @property (assign, nonatomic) CGFloat labelLeftInset; 14 | /** 显示刷新状态的label */ 15 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 16 | /** 设置state状态下的文字 */ 17 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 18 | 19 | /** 获取state状态下的title */ 20 | - (NSString *)titleForState:(MJRefreshState)state; 21 | @end 22 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/zh-Hant.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "MJRefreshHeaderIdleText" = "下拉可以刷新"; 2 | "MJRefreshHeaderPullingText" = "鬆開立即刷新"; 3 | "MJRefreshHeaderRefreshingText" = "正在刷新數據中..."; 4 | 5 | "MJRefreshAutoFooterIdleText" = "點擊或上拉加載更多"; 6 | "MJRefreshAutoFooterRefreshingText" = "正在加載更多的數據..."; 7 | "MJRefreshAutoFooterNoMoreDataText" = "已經全部加載完畢"; 8 | 9 | "MJRefreshBackFooterIdleText" = "上拉可以加載更多"; 10 | "MJRefreshBackFooterPullingText" = "鬆開立即加載更多"; 11 | "MJRefreshBackFooterRefreshingText" = "正在加載更多的數據..."; 12 | "MJRefreshBackFooterNoMoreDataText" = "已經全部加載完畢"; 13 | 14 | "MJRefreshHeaderLastTimeText" = "最後更新:"; 15 | "MJRefreshHeaderDateTodayText" = "今天"; 16 | "MJRefreshHeaderNoneLastDateText" = "無記錄"; 17 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MJRefresh (3.1.12) 3 | - WYNullView (1.0.2): 4 | - WYNullView/Category (= 1.0.2) 5 | - WYNullView/Tool (= 1.0.2) 6 | - WYNullView/View (= 1.0.2) 7 | - WYNullView/Category (1.0.2): 8 | - WYNullView/Tool 9 | - WYNullView/View 10 | - WYNullView/Tool (1.0.2) 11 | - WYNullView/View (1.0.2) 12 | 13 | DEPENDENCIES: 14 | - MJRefresh (~> 3.1.1) 15 | - WYNullView (from `../../`) 16 | 17 | EXTERNAL SOURCES: 18 | WYNullView: 19 | :path: ../../ 20 | 21 | SPEC CHECKSUMS: 22 | MJRefresh: b96cdb21c4aa75a7b07654311ab2f315c497e806 23 | WYNullView: c4d1b5cac04cb3f86f0b5b8bfc40883ad3c62550 24 | 25 | PODFILE CHECKSUM: 687436f630ad2a20db75b6186bcdb8d9c669aba6 26 | 27 | COCOAPODS: 1.2.0.beta.1 28 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter : MJRefreshAutoFooter 12 | /** 文字距离圈圈、箭头的距离 */ 13 | @property (assign, nonatomic) CGFloat labelLeftInset; 14 | /** 显示刷新状态的label */ 15 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 16 | 17 | /** 设置state状态下的文字 */ 18 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 19 | 20 | /** 隐藏刷新状态的文字 */ 21 | @property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; 22 | @end 23 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - MJRefresh (3.1.12) 3 | - WYNullView (1.0.2): 4 | - WYNullView/Category (= 1.0.2) 5 | - WYNullView/Tool (= 1.0.2) 6 | - WYNullView/View (= 1.0.2) 7 | - WYNullView/Category (1.0.2): 8 | - WYNullView/Tool 9 | - WYNullView/View 10 | - WYNullView/Tool (1.0.2) 11 | - WYNullView/View (1.0.2) 12 | 13 | DEPENDENCIES: 14 | - MJRefresh (~> 3.1.1) 15 | - WYNullView (from `../../`) 16 | 17 | EXTERNAL SOURCES: 18 | WYNullView: 19 | :path: ../../ 20 | 21 | SPEC CHECKSUMS: 22 | MJRefresh: b96cdb21c4aa75a7b07654311ab2f315c497e806 23 | WYNullView: c4d1b5cac04cb3f86f0b5b8bfc40883ad3c62550 24 | 25 | PODFILE CHECKSUM: 687436f630ad2a20db75b6186bcdb8d9c669aba6 26 | 27 | COCOAPODS: 1.2.0.beta.1 28 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/NSString+TextHeight.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+TextHeight.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "NSString+TextHeight.h" 10 | 11 | @implementation NSString (TextHeight) 12 | 13 | /** 给定最大宽度和字号 返回实际高度 */ 14 | - (CGFloat)wy_getHeightWithMaxWidth:(CGFloat)maxWidth font:(UIFont *)font{ 15 | CGSize textMaxSize = CGSizeMake(maxWidth, MAXFLOAT); 16 | NSDictionary *textFontDict = @{NSFontAttributeName:font}; 17 | CGRect textContentRect = [self boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:textFontDict context:nil]; 18 | return textContentRect.size.height; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/WYNullView" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh/MJRefresh.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/WYNullView/WYNullView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "MJRefresh" -framework "WYNullView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/WYNullView" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh/MJRefresh.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/WYNullView/WYNullView.framework/Headers" 5 | OTHER_LDFLAGS = $(inherited) -framework "MJRefresh" -framework "WYNullView" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshFooter.h" 10 | 11 | @interface MJRefreshAutoFooter : MJRefreshFooter 12 | /** 是否自动刷新(默认为YES) */ 13 | @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; 14 | 15 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 16 | @property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("请使用triggerAutomaticallyRefreshPercent属性"); 17 | 18 | /** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ 19 | @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; 20 | @end 21 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/UIView+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIView+Extension.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | @interface UIView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_x; 14 | @property (assign, nonatomic) CGFloat mj_y; 15 | @property (assign, nonatomic) CGFloat mj_w; 16 | @property (assign, nonatomic) CGFloat mj_h; 17 | @property (assign, nonatomic) CGSize mj_size; 18 | @property (assign, nonatomic) CGPoint mj_origin; 19 | @end 20 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshStateHeader.h 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshHeader.h" 10 | 11 | @interface MJRefreshStateHeader : MJRefreshHeader 12 | #pragma mark - 刷新时间相关 13 | /** 利用这个block来决定显示的更新时间文字 */ 14 | @property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime); 15 | /** 显示上一次刷新时间的label */ 16 | @property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; 17 | 18 | #pragma mark - 状态相关 19 | /** 文字距离圈圈、箭头的距离 */ 20 | @property (assign, nonatomic) CGFloat labelLeftInset; 21 | /** 显示刷新状态的label */ 22 | @property (weak, nonatomic, readonly) UILabel *stateLabel; 23 | /** 设置state状态下的文字 */ 24 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state; 25 | @end 26 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import 11 | 12 | @interface UIScrollView (MJExtension) 13 | @property (assign, nonatomic) CGFloat mj_insetT; 14 | @property (assign, nonatomic) CGFloat mj_insetB; 15 | @property (assign, nonatomic) CGFloat mj_insetL; 16 | @property (assign, nonatomic) CGFloat mj_insetR; 17 | 18 | @property (assign, nonatomic) CGFloat mj_offsetX; 19 | @property (assign, nonatomic) CGFloat mj_offsetY; 20 | 21 | @property (assign, nonatomic) CGFloat mj_contentW; 22 | @property (assign, nonatomic) CGFloat mj_contentH; 23 | @end 24 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/MJRefresh/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.1.12 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/WYNullView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshHeader.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 下拉刷新控件:负责监控用户下拉的状态 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshHeader : MJRefreshComponent 13 | /** 创建header */ 14 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建header */ 16 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 这个key用来存储上一次下拉刷新成功的时间 */ 19 | @property (copy, nonatomic) NSString *lastUpdatedTimeKey; 20 | /** 上一次下拉刷新成功的时间 */ 21 | @property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; 22 | 23 | /** 忽略多少scrollView的contentInset的top */ 24 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; 25 | @end 26 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 给ScrollView增加下拉刷新、上拉刷新的功能 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | 13 | @class MJRefreshHeader, MJRefreshFooter; 14 | 15 | @interface UIScrollView (MJRefresh) 16 | /** 下拉刷新控件 */ 17 | @property (strong, nonatomic) MJRefreshHeader *mj_header; 18 | @property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header"); 19 | /** 上拉刷新控件 */ 20 | @property (strong, nonatomic) MJRefreshFooter *mj_footer; 21 | @property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer"); 22 | 23 | #pragma mark - other 24 | - (NSInteger)mj_totalDataCount; 25 | @property (copy, nonatomic) void (^mj_reloadDataBlock)(NSInteger totalDataCount); 26 | @end 27 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemoTests/WYNullViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WYNullViewDemoTests.m 3 | // WYNullViewDemoTests 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WYNullViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WYNullViewDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 WYNullView (https://github.com/WymanLyu/WYNullView) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/MJRefresh/MJRefresh-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "MJRefreshAutoFooter.h" 14 | #import "MJRefreshBackFooter.h" 15 | #import "MJRefreshComponent.h" 16 | #import "MJRefreshFooter.h" 17 | #import "MJRefreshHeader.h" 18 | #import "MJRefreshAutoGifFooter.h" 19 | #import "MJRefreshAutoNormalFooter.h" 20 | #import "MJRefreshAutoStateFooter.h" 21 | #import "MJRefreshBackGifFooter.h" 22 | #import "MJRefreshBackNormalFooter.h" 23 | #import "MJRefreshBackStateFooter.h" 24 | #import "MJRefreshGifHeader.h" 25 | #import "MJRefreshNormalHeader.h" 26 | #import "MJRefreshStateHeader.h" 27 | #import "MJRefresh.h" 28 | #import "MJRefreshConst.h" 29 | #import "NSBundle+MJRefresh.h" 30 | #import "UIScrollView+MJExtension.h" 31 | #import "UIScrollView+MJRefresh.h" 32 | #import "UIView+MJExtension.h" 33 | 34 | FOUNDATION_EXPORT double MJRefreshVersionNumber; 35 | FOUNDATION_EXPORT const unsigned char MJRefreshVersionString[]; 36 | 37 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "size" : "40x40", 25 | "idiom" : "iphone", 26 | "filename" : "AppIcon-40x40@2x.png", 27 | "scale" : "2x" 28 | }, 29 | { 30 | "size" : "40x40", 31 | "idiom" : "iphone", 32 | "filename" : "AppIcon-40x40@3x.png", 33 | "scale" : "3x" 34 | }, 35 | { 36 | "size" : "60x60", 37 | "idiom" : "iphone", 38 | "filename" : "AppIcon-60x60@2x.png", 39 | "scale" : "2x" 40 | }, 41 | { 42 | "size" : "60x60", 43 | "idiom" : "iphone", 44 | "filename" : "AppIcon-60x60@3x.png", 45 | "scale" : "3x" 46 | } 47 | ], 48 | "info" : { 49 | "version" : 1, 50 | "author" : "xcode" 51 | } 52 | } -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 上拉刷新控件 9 | 10 | #import "MJRefreshComponent.h" 11 | 12 | @interface MJRefreshFooter : MJRefreshComponent 13 | /** 创建footer */ 14 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 15 | /** 创建footer */ 16 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 17 | 18 | /** 提示没有更多的数据 */ 19 | - (void)endRefreshingWithNoMoreData; 20 | - (void)noticeNoMoreData MJRefreshDeprecated("使用endRefreshingWithNoMoreData"); 21 | 22 | /** 重置没有更多的数据(消除没有更多数据的状态) */ 23 | - (void)resetNoMoreData; 24 | 25 | /** 忽略多少scrollView的contentInset的bottom */ 26 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; 27 | 28 | /** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏。默认是NO) */ 29 | @property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden; 30 | @end 31 | -------------------------------------------------------------------------------- /WYNullView/View/NSBundle+WY.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+WY.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/30. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "NSBundle+WY.h" 10 | 11 | @implementation NSBundle (WY) 12 | 13 | + (instancetype)wy_nullViewBundle { 14 | static NSBundle *nullViewBundle = nil; 15 | if (nil == nullViewBundle) { 16 | nullViewBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:NSClassFromString(@"NullView")] pathForResource:@"WYNullView" ofType:@"bundle"]]; 17 | } 18 | return nullViewBundle; 19 | } 20 | 21 | + (UIImage *)wy_nullViewImage { 22 | // this func can't load image from xcassets in custom bundle i dont know why? 在bundle的xcassets怎么加载图片,这样我需要加载3x、2x要自己判断 23 | // rerurn [UIImage imageNamed:@"null_img" inBundle:[self wy_nullViewBundle] compatibleWithTraitCollection:nil]; 24 | static UIImage *nullImage = nil; 25 | if (nil == nullImage) { 26 | nullImage = [UIImage imageWithContentsOfFile:[[self wy_nullViewBundle] pathForResource:@"null_img@2x" ofType:@"png"]]; 27 | } 28 | return nullImage; 29 | } 30 | 31 | + (NSMutableArray *)wy_classWhitelistArrayM { 32 | NSString *plistPath = [[self wy_nullViewBundle] pathForResource:@"ClassWhitelist" ofType:@"plist"]; 33 | return [[NSMutableArray alloc] initWithContentsOfFile:plistPath]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemoUITests/WYNullViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WYNullViewDemoUITests.m 3 | // WYNullViewDemoUITests 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface WYNullViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WYNullViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Local Podspecs/WYNullView.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "WYNullView", 3 | "version": "1.0.2", 4 | "summary": "An easy way to use when view' content is empty", 5 | "description": "This lib has been designed in a way where you won't need to extend UIView class. You will be able to fully customize the content and appearance of the empty states for your application", 6 | "homepage": "https://github.com/WymanLyu/WYNullView", 7 | "license": "MIT", 8 | "authors": { 9 | "wyman": "wyman.lyu@gmail.com" 10 | }, 11 | "platforms": { 12 | "ios": "5.0" 13 | }, 14 | "source": { 15 | "git": "https://github.com/WymanLyu/WYNullView.git", 16 | "tag": "1.0.2" 17 | }, 18 | "source_files": "WYNullView/WYNullView.h", 19 | "public_header_files": "WYNullView/WYNullView.h", 20 | "resources": "WYNullView/WYNullView.bundle", 21 | "subspecs": [ 22 | { 23 | "name": "Tool", 24 | "source_files": "WYNullView/Tool/*.{h,m}", 25 | "public_header_files": "WYNullView/Tool/*.h" 26 | }, 27 | { 28 | "name": "View", 29 | "source_files": "WYNullView/View/*.{h,m}", 30 | "public_header_files": "WYNullView/View/*.h" 31 | }, 32 | { 33 | "name": "Category", 34 | "dependencies": { 35 | "WYNullView/View": [ 36 | 37 | ], 38 | "WYNullView/Tool": [ 39 | 40 | ] 41 | }, 42 | "source_files": "WYNullView/Category/*.{h,m}", 43 | "public_header_files": "WYNullView/Category/*.h" 44 | } 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /WYNullView/Category/UIView+WYNullView.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+WY.h 3 | // 5-20静默视图 4 | // 5 | // Created by wyman on 2017/5/20. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NullView.h" 11 | #import "UIView+HiddenEx.h" 12 | 13 | typedef UIView *(^NullViewHandle)(NullView *defaultNullView); 14 | 15 | @interface UIView (WYNullView) 16 | 17 | #pragma mark - 静默视图 18 | 19 | ///> 空视图 20 | @property (nonatomic, strong) UIView *wy_nullView; 21 | 22 | /** 配置空视图样式 */ 23 | - (void)wy_configNullView:(UIView *(^)(NullView *defaultNullView))nullViewConfig; 24 | 25 | /** 配置空视图点击操作 */ 26 | - (void)wy_nullViewAddTarget:(id)target action:(SEL)sel; 27 | 28 | /** 显示空视图 29 | * nullViewHandle : 修改空视图样式,如果为空则会按照wy_configNullView的样式, 如果没有配置wy_configNullView则是默认样式 30 | * offset : 调整垂直方向的间距 31 | */ 32 | - (void)wy_showNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle heightOffset:(CGFloat)offset; 33 | 34 | /** 显示空视图 35 | * nullViewHandle : 修改空视图样式,如果为空则会按照wy_configNullView的样式, 如果没有配置wy_configNullView则是默认样式 36 | */ 37 | - (void)wy_showNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle; 38 | 39 | /** 显示空视图 */ 40 | - (void)wy_showNullView; 41 | 42 | /** 隐藏空视图 */ 43 | - (void)wy_hideNullView; 44 | 45 | /** 配置默认的NullView */ 46 | + (void)wy_configGlobleNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle; 47 | 48 | ///> 加载视图 49 | @property (nonatomic, strong) UIView *wy_loadingView; 50 | 51 | @property (nonatomic, strong) UIView *wy_loadingMaskView; 52 | 53 | /** 开始加载【默认是隐藏其他视图】 */ 54 | - (void)wy_startLodingHideOtherView; 55 | 56 | /** 开始加载【默认是不隐藏其他视图】 */ 57 | - (void)wy_startLoding; 58 | 59 | /** 停止加载 */ 60 | - (void)wy_stopLoding; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /WYNullView/WYNullView.bundle/Root.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | StringsTable 6 | Root 7 | PreferenceSpecifiers 8 | 9 | 10 | Type 11 | PSGroupSpecifier 12 | Title 13 | Group 14 | 15 | 16 | Type 17 | PSTextFieldSpecifier 18 | Title 19 | Name 20 | Key 21 | name_preference 22 | DefaultValue 23 | 24 | IsSecure 25 | 26 | KeyboardType 27 | Alphabet 28 | AutocapitalizationType 29 | None 30 | AutocorrectionType 31 | No 32 | 33 | 34 | Type 35 | PSToggleSwitchSpecifier 36 | Title 37 | Enabled 38 | Key 39 | enabled_preference 40 | DefaultValue 41 | 42 | 43 | 44 | Type 45 | PSSliderSpecifier 46 | Key 47 | slider_preference 48 | DefaultValue 49 | 0.5 50 | MinimumValue 51 | 0 52 | MaximumValue 53 | 1 54 | MinimumValueImage 55 | 56 | MaximumValueImage 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/UIView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIView+MJExtension.h" 11 | 12 | @implementation UIView (MJExtension) 13 | - (void)setMj_x:(CGFloat)mj_x 14 | { 15 | CGRect frame = self.frame; 16 | frame.origin.x = mj_x; 17 | self.frame = frame; 18 | } 19 | 20 | - (CGFloat)mj_x 21 | { 22 | return self.frame.origin.x; 23 | } 24 | 25 | - (void)setMj_y:(CGFloat)mj_y 26 | { 27 | CGRect frame = self.frame; 28 | frame.origin.y = mj_y; 29 | self.frame = frame; 30 | } 31 | 32 | - (CGFloat)mj_y 33 | { 34 | return self.frame.origin.y; 35 | } 36 | 37 | - (void)setMj_w:(CGFloat)mj_w 38 | { 39 | CGRect frame = self.frame; 40 | frame.size.width = mj_w; 41 | self.frame = frame; 42 | } 43 | 44 | - (CGFloat)mj_w 45 | { 46 | return self.frame.size.width; 47 | } 48 | 49 | - (void)setMj_h:(CGFloat)mj_h 50 | { 51 | CGRect frame = self.frame; 52 | frame.size.height = mj_h; 53 | self.frame = frame; 54 | } 55 | 56 | - (CGFloat)mj_h 57 | { 58 | return self.frame.size.height; 59 | } 60 | 61 | - (void)setMj_size:(CGSize)mj_size 62 | { 63 | CGRect frame = self.frame; 64 | frame.size = mj_size; 65 | self.frame = frame; 66 | } 67 | 68 | - (CGSize)mj_size 69 | { 70 | return self.frame.size; 71 | } 72 | 73 | - (void)setMj_origin:(CGPoint)mj_origin 74 | { 75 | CGRect frame = self.frame; 76 | frame.origin = mj_origin; 77 | self.frame = frame; 78 | } 79 | 80 | - (CGPoint)mj_origin 81 | { 82 | return self.frame.origin; 83 | } 84 | @end 85 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefreshConst.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | 5 | const CGFloat MJRefreshLabelLeftInset = 25; 6 | const CGFloat MJRefreshHeaderHeight = 54.0; 7 | const CGFloat MJRefreshFooterHeight = 44.0; 8 | const CGFloat MJRefreshFastAnimationDuration = 0.25; 9 | const CGFloat MJRefreshSlowAnimationDuration = 0.4; 10 | 11 | NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; 12 | NSString *const MJRefreshKeyPathContentInset = @"contentInset"; 13 | NSString *const MJRefreshKeyPathContentSize = @"contentSize"; 14 | NSString *const MJRefreshKeyPathPanState = @"state"; 15 | 16 | NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; 17 | 18 | NSString *const MJRefreshHeaderIdleText = @"MJRefreshHeaderIdleText"; 19 | NSString *const MJRefreshHeaderPullingText = @"MJRefreshHeaderPullingText"; 20 | NSString *const MJRefreshHeaderRefreshingText = @"MJRefreshHeaderRefreshingText"; 21 | 22 | NSString *const MJRefreshAutoFooterIdleText = @"MJRefreshAutoFooterIdleText"; 23 | NSString *const MJRefreshAutoFooterRefreshingText = @"MJRefreshAutoFooterRefreshingText"; 24 | NSString *const MJRefreshAutoFooterNoMoreDataText = @"MJRefreshAutoFooterNoMoreDataText"; 25 | 26 | NSString *const MJRefreshBackFooterIdleText = @"MJRefreshBackFooterIdleText"; 27 | NSString *const MJRefreshBackFooterPullingText = @"MJRefreshBackFooterPullingText"; 28 | NSString *const MJRefreshBackFooterRefreshingText = @"MJRefreshBackFooterRefreshingText"; 29 | NSString *const MJRefreshBackFooterNoMoreDataText = @"MJRefreshBackFooterNoMoreDataText"; 30 | 31 | NSString *const MJRefreshHeaderLastTimeText = @"MJRefreshHeaderLastTimeText"; 32 | NSString *const MJRefreshHeaderDateTodayText = @"MJRefreshHeaderDateTodayText"; 33 | NSString *const MJRefreshHeaderNoneLastDateText = @"MJRefreshHeaderNoneLastDateText"; -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoNormalFooter.h" 10 | 11 | @interface MJRefreshAutoNormalFooter() 12 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 13 | @end 14 | 15 | @implementation MJRefreshAutoNormalFooter 16 | #pragma mark - 懒加载子控件 17 | - (UIActivityIndicatorView *)loadingView 18 | { 19 | if (!_loadingView) { 20 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 21 | loadingView.hidesWhenStopped = YES; 22 | [self addSubview:_loadingView = loadingView]; 23 | } 24 | return _loadingView; 25 | } 26 | 27 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 28 | { 29 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 30 | 31 | self.loadingView = nil; 32 | [self setNeedsLayout]; 33 | } 34 | #pragma mark - 重写父类的方法 35 | - (void)prepare 36 | { 37 | [super prepare]; 38 | 39 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 40 | } 41 | 42 | - (void)placeSubviews 43 | { 44 | [super placeSubviews]; 45 | 46 | if (self.loadingView.constraints.count) return; 47 | 48 | // 圈圈 49 | CGFloat loadingCenterX = self.mj_w * 0.5; 50 | if (!self.isRefreshingTitleHidden) { 51 | loadingCenterX -= self.stateLabel.mj_textWith * 0.5 + self.labelLeftInset; 52 | } 53 | CGFloat loadingCenterY = self.mj_h * 0.5; 54 | self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); 55 | } 56 | 57 | - (void)setState:(MJRefreshState)state 58 | { 59 | MJRefreshCheckState 60 | 61 | // 根据状态做事情 62 | if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 63 | [self.loadingView stopAnimating]; 64 | } else if (state == MJRefreshStateRefreshing) { 65 | [self.loadingView startAnimating]; 66 | } 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshFooter.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/5. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshFooter.h" 11 | 12 | @interface MJRefreshFooter() 13 | 14 | @end 15 | 16 | @implementation MJRefreshFooter 17 | #pragma mark - 构造方法 18 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock 19 | { 20 | MJRefreshFooter *cmp = [[self alloc] init]; 21 | cmp.refreshingBlock = refreshingBlock; 22 | return cmp; 23 | } 24 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action 25 | { 26 | MJRefreshFooter *cmp = [[self alloc] init]; 27 | [cmp setRefreshingTarget:target refreshingAction:action]; 28 | return cmp; 29 | } 30 | 31 | #pragma mark - 重写父类的方法 32 | - (void)prepare 33 | { 34 | [super prepare]; 35 | 36 | // 设置自己的高度 37 | self.mj_h = MJRefreshFooterHeight; 38 | 39 | // 默认不会自动隐藏 40 | self.automaticallyHidden = NO; 41 | } 42 | 43 | - (void)willMoveToSuperview:(UIView *)newSuperview 44 | { 45 | [super willMoveToSuperview:newSuperview]; 46 | 47 | if (newSuperview) { 48 | // 监听scrollView数据的变化 49 | if ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) { 50 | [self.scrollView setMj_reloadDataBlock:^(NSInteger totalDataCount) { 51 | if (self.isAutomaticallyHidden) { 52 | self.hidden = (totalDataCount == 0); 53 | } 54 | }]; 55 | } 56 | } 57 | } 58 | 59 | #pragma mark - 公共方法 60 | - (void)endRefreshingWithNoMoreData 61 | { 62 | self.state = MJRefreshStateNoMoreData; 63 | } 64 | 65 | - (void)noticeNoMoreData 66 | { 67 | [self endRefreshingWithNoMoreData]; 68 | } 69 | 70 | - (void)resetNoMoreData 71 | { 72 | self.state = MJRefreshStateIdle; 73 | } 74 | @end 75 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /WYNullView/View/NullView.m: -------------------------------------------------------------------------------- 1 | // 2 | // NullView.m 3 | // HeiPa 4 | // 5 | // Created by wyman on 2017/3/14. 6 | // Copyright © 2017年 tykj. All rights reserved. 7 | // 8 | 9 | #import "NullView.h" 10 | #import "NSBundle+WY.h" 11 | 12 | @interface NullView () 13 | 14 | @property (nonatomic, weak) UIImageView *iconView; 15 | 16 | @property (nonatomic, weak) UILabel *desLbl; 17 | 18 | @end 19 | 20 | @implementation NullView 21 | 22 | - (instancetype)initWithFrame:(CGRect)frame { 23 | if (self = [super initWithFrame:frame]) { 24 | 25 | // 0.图标 26 | UIImageView *iconView = [[UIImageView alloc] init]; 27 | iconView.image = [NSBundle wy_nullViewImage]; 28 | [self addSubview:iconView]; 29 | _iconView = iconView; 30 | 31 | // 1.说明 32 | UILabel *desLbl = [UILabel new]; 33 | desLbl.text = @"当前无内容"; 34 | desLbl.font = [UIFont systemFontOfSize:12]; 35 | desLbl.textColor = [UIColor lightGrayColor]; 36 | desLbl.textAlignment = NSTextAlignmentCenter; 37 | [self addSubview:desLbl]; 38 | _desLbl = desLbl; 39 | 40 | } 41 | return self; 42 | } 43 | 44 | - (void)setFrame:(CGRect)frame { 45 | CGRect tempRect = frame; 46 | tempRect.size.width = NULL_WIDTH; 47 | tempRect.size.height = NULL_HEIGHT; 48 | [super setFrame:tempRect]; 49 | } 50 | 51 | - (void)layoutSubviews { 52 | [super layoutSubviews]; 53 | CGRect superRect = self.bounds; 54 | // 图标居中往上 55 | CGFloat iconW = 90; 56 | CGFloat iconH = 128; 57 | CGFloat iconX = superRect.size.width*0.5 - iconW*0.5; 58 | CGFloat iconY = 0; 59 | self.iconView.frame = CGRectMake(iconX, iconY, iconW, iconH); 60 | 61 | // 说明 62 | CGFloat desW = iconW; 63 | CGFloat desH = 22; 64 | CGFloat desX = superRect.size.width*0.5 - desW*0.5; 65 | CGFloat desY = CGRectGetMaxY( self.iconView.frame) + 15; 66 | self.desLbl.frame = CGRectMake(desX, desY, desW, desH); 67 | } 68 | 69 | - (void)setNullIconImageName:(NSString *)nullIconImageName { 70 | _nullIconImageName = nullIconImageName; 71 | self.iconView.image = [UIImage imageNamed:_nullIconImageName]; 72 | } 73 | 74 | - (void)setDesText:(NSString *)desText { 75 | _desText = desText; 76 | self.desLbl.text = _desText; 77 | } 78 | 79 | @end 80 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/NSBundle+MJRefresh.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSBundle+MJRefresh.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 16/6/13. 6 | // Copyright © 2016年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "NSBundle+MJRefresh.h" 10 | #import "MJRefreshComponent.h" 11 | 12 | @implementation NSBundle (MJRefresh) 13 | + (instancetype)mj_refreshBundle 14 | { 15 | static NSBundle *refreshBundle = nil; 16 | if (refreshBundle == nil) { 17 | // 这里不使用mainBundle是为了适配pod 1.x和0.x 18 | refreshBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[MJRefreshComponent class]] pathForResource:@"MJRefresh" ofType:@"bundle"]]; 19 | } 20 | return refreshBundle; 21 | } 22 | 23 | + (UIImage *)mj_arrowImage 24 | { 25 | static UIImage *arrowImage = nil; 26 | if (arrowImage == nil) { 27 | arrowImage = [[UIImage imageWithContentsOfFile:[[self mj_refreshBundle] pathForResource:@"arrow@2x" ofType:@"png"]] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 28 | } 29 | return arrowImage; 30 | } 31 | 32 | + (NSString *)mj_localizedStringForKey:(NSString *)key 33 | { 34 | return [self mj_localizedStringForKey:key value:nil]; 35 | } 36 | 37 | + (NSString *)mj_localizedStringForKey:(NSString *)key value:(NSString *)value 38 | { 39 | static NSBundle *bundle = nil; 40 | if (bundle == nil) { 41 | // (iOS获取的语言字符串比较不稳定)目前框架只处理en、zh-Hans、zh-Hant三种情况,其他按照系统默认处理 42 | NSString *language = [NSLocale preferredLanguages].firstObject; 43 | if ([language hasPrefix:@"en"]) { 44 | language = @"en"; 45 | } else if ([language hasPrefix:@"zh"]) { 46 | if ([language rangeOfString:@"Hans"].location != NSNotFound) { 47 | language = @"zh-Hans"; // 简体中文 48 | } else { // zh-Hant\zh-HK\zh-TW 49 | language = @"zh-Hant"; // 繁體中文 50 | } 51 | } else { 52 | language = @"en"; 53 | } 54 | 55 | // 从MJRefresh.bundle中查找资源 56 | bundle = [NSBundle bundleWithPath:[[NSBundle mj_refreshBundle] pathForResource:language ofType:@"lproj"]]; 57 | } 58 | value = [bundle localizedStringForKey:key value:value table:nil]; 59 | return [[NSBundle mainBundle] localizedStringForKey:key value:value table:nil]; 60 | } 61 | @end 62 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackStateFooter.h" 10 | 11 | @interface MJRefreshBackStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshBackStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel mj_label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | - (NSString *)titleForState:(MJRefreshState)state { 47 | return self.stateTitles[@(state)]; 48 | } 49 | 50 | #pragma mark - 重写父类的方法 51 | - (void)prepare 52 | { 53 | [super prepare]; 54 | 55 | // 初始化间距 56 | self.labelLeftInset = MJRefreshLabelLeftInset; 57 | 58 | // 初始化文字 59 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterIdleText] forState:MJRefreshStateIdle]; 60 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterPullingText] forState:MJRefreshStatePulling]; 61 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterRefreshingText] forState:MJRefreshStateRefreshing]; 62 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshBackFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; 63 | } 64 | 65 | - (void)placeSubviews 66 | { 67 | [super placeSubviews]; 68 | 69 | if (self.stateLabel.constraints.count) return; 70 | 71 | // 状态标签 72 | self.stateLabel.frame = self.bounds; 73 | } 74 | 75 | - (void)setState:(MJRefreshState)state 76 | { 77 | MJRefreshCheckState 78 | 79 | // 设置状态文字 80 | self.stateLabel.text = self.stateTitles[@(state)]; 81 | } 82 | @end 83 | -------------------------------------------------------------------------------- /WYNullView/View/LoadingView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LoadingView.m 3 | // HeiPa 4 | // 5 | // Created by wyman on 2017/3/14. 6 | // Copyright © 2017年 tykj. All rights reserved. 7 | // 8 | 9 | #import "LoadingView.h" 10 | 11 | @interface LoadingView () 12 | 13 | @property (nonatomic, weak) CAShapeLayer *cycleLayer; 14 | 15 | @property (nonatomic, assign) BOOL isLoading; 16 | 17 | @end 18 | 19 | @implementation LoadingView 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame { 22 | if (self = [super initWithFrame:frame]) { 23 | 24 | // 圆圈 25 | CAShapeLayer *cycleLayer = [CAShapeLayer new]; 26 | cycleLayer.lineCap = kCALineCapRound; 27 | cycleLayer.lineJoin = kCALineJoinRound; 28 | cycleLayer.fillColor = [UIColor clearColor].CGColor; 29 | cycleLayer.strokeColor = [UIColor blackColor].CGColor; 30 | cycleLayer.lineWidth = 4.0; 31 | cycleLayer.strokeEnd = 0; 32 | [self.layer addSublayer:cycleLayer]; 33 | _cycleLayer = cycleLayer; 34 | 35 | } 36 | return self; 37 | } 38 | 39 | - (void)layoutSubviews { 40 | [super layoutSubviews]; 41 | self.cycleLayer.frame = self.bounds; 42 | self.cycleLayer.path = [UIBezierPath bezierPathWithOvalInRect:self.bounds].CGPath; 43 | } 44 | 45 | - (void)startLoading { 46 | 47 | if (self.isLoading) { 48 | return; 49 | } 50 | 51 | self.isLoading = YES; 52 | self.alpha = 1.0; 53 | 54 | CABasicAnimation *strokeStartAnimation = [CABasicAnimation animation]; 55 | strokeStartAnimation.keyPath = @"strokeStart"; 56 | strokeStartAnimation.fromValue = @(-1); 57 | strokeStartAnimation.toValue = @(1.0); 58 | 59 | CABasicAnimation *strokeEndAnimation = [CABasicAnimation animation]; 60 | strokeEndAnimation.keyPath = @"strokeEnd"; 61 | strokeEndAnimation.fromValue = @(0); 62 | strokeEndAnimation.toValue = @(1.0); 63 | 64 | CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; 65 | animationGroup.duration = 1; 66 | animationGroup.repeatCount = MAXFLOAT; 67 | animationGroup.animations = @[strokeStartAnimation, strokeEndAnimation]; 68 | [self.cycleLayer addAnimation:animationGroup forKey:@"animationGroup"]; 69 | 70 | } 71 | 72 | - (void)stopLoading { 73 | 74 | if (!self.isLoading) { 75 | return; 76 | } 77 | 78 | [UIView animateWithDuration:0.2 animations:^{ 79 | self.alpha = 0; 80 | } completion:^(BOOL finished) { 81 | [self.cycleLayer removeAllAnimations]; 82 | _isLoading = NO; 83 | }]; 84 | 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## MJRefresh 5 | 6 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | 27 | ## WYNullView 28 | 29 | Copyright (c) 2013-2015 WYNullView (https://github.com/WymanLyu/WYNullView) 30 | 31 | Permission is hereby granted, free of charge, to any person obtaining a copy 32 | of this software and associated documentation files (the "Software"), to deal 33 | in the Software without restriction, including without limitation the rights 34 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 35 | copies of the Software, and to permit persons to whom the Software is 36 | furnished to do so, subject to the following conditions: 37 | 38 | The above copyright notice and this permission notice shall be included in 39 | all copies or substantial portions of the Software. 40 | 41 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 42 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 43 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 44 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 45 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 46 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 47 | THE SOFTWARE. 48 | Generated by CocoaPods - https://cocoapods.org 49 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoStateFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/6/13. 6 | // Copyright © 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoStateFooter.h" 10 | 11 | @interface MJRefreshAutoStateFooter() 12 | { 13 | /** 显示刷新状态的label */ 14 | __unsafe_unretained UILabel *_stateLabel; 15 | } 16 | /** 所有状态对应的文字 */ 17 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 18 | @end 19 | 20 | @implementation MJRefreshAutoStateFooter 21 | #pragma mark - 懒加载 22 | - (NSMutableDictionary *)stateTitles 23 | { 24 | if (!_stateTitles) { 25 | self.stateTitles = [NSMutableDictionary dictionary]; 26 | } 27 | return _stateTitles; 28 | } 29 | 30 | - (UILabel *)stateLabel 31 | { 32 | if (!_stateLabel) { 33 | [self addSubview:_stateLabel = [UILabel mj_label]]; 34 | } 35 | return _stateLabel; 36 | } 37 | 38 | #pragma mark - 公共方法 39 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 40 | { 41 | if (title == nil) return; 42 | self.stateTitles[@(state)] = title; 43 | self.stateLabel.text = self.stateTitles[@(self.state)]; 44 | } 45 | 46 | #pragma mark - 私有方法 47 | - (void)stateLabelClick 48 | { 49 | if (self.state == MJRefreshStateIdle) { 50 | [self beginRefreshing]; 51 | } 52 | } 53 | 54 | #pragma mark - 重写父类的方法 55 | - (void)prepare 56 | { 57 | [super prepare]; 58 | 59 | // 初始化间距 60 | self.labelLeftInset = MJRefreshLabelLeftInset; 61 | 62 | // 初始化文字 63 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterIdleText] forState:MJRefreshStateIdle]; 64 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterRefreshingText] forState:MJRefreshStateRefreshing]; 65 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshAutoFooterNoMoreDataText] forState:MJRefreshStateNoMoreData]; 66 | 67 | // 监听label 68 | self.stateLabel.userInteractionEnabled = YES; 69 | [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; 70 | } 71 | 72 | - (void)placeSubviews 73 | { 74 | [super placeSubviews]; 75 | 76 | if (self.stateLabel.constraints.count) return; 77 | 78 | // 状态标签 79 | self.stateLabel.frame = self.bounds; 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { 87 | self.stateLabel.text = nil; 88 | } else { 89 | self.stateLabel.text = self.stateTitles[@(state)]; 90 | } 91 | } 92 | @end -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/MJRefreshConst.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | #import 4 | #import 5 | 6 | // 弱引用 7 | #define MJWeakSelf __weak typeof(self) weakSelf = self; 8 | 9 | // 日志输出 10 | #ifdef DEBUG 11 | #define MJRefreshLog(...) NSLog(__VA_ARGS__) 12 | #else 13 | #define MJRefreshLog(...) 14 | #endif 15 | 16 | // 过期提醒 17 | #define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) 18 | 19 | // 运行时objc_msgSend 20 | #define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) 21 | #define MJRefreshMsgTarget(target) (__bridge void *)(target) 22 | 23 | // RGB颜色 24 | #define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] 25 | 26 | // 文字颜色 27 | #define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) 28 | 29 | // 字体大小 30 | #define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] 31 | 32 | // 常量 33 | UIKIT_EXTERN const CGFloat MJRefreshLabelLeftInset; 34 | UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; 35 | UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; 36 | UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; 37 | UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; 38 | 39 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; 40 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; 41 | UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; 42 | UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; 43 | 44 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; 45 | 46 | UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; 47 | UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; 48 | UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; 49 | 50 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; 51 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; 52 | UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; 53 | 54 | UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; 55 | UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; 56 | UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; 57 | UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; 58 | 59 | UIKIT_EXTERN NSString *const MJRefreshHeaderLastTimeText; 60 | UIKIT_EXTERN NSString *const MJRefreshHeaderDateTodayText; 61 | UIKIT_EXTERN NSString *const MJRefreshHeaderNoneLastDateText; 62 | 63 | // 状态检查 64 | #define MJRefreshCheckState \ 65 | MJRefreshState oldState = self.state; \ 66 | if (state == oldState) return; \ 67 | [super setState:state]; 68 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+Extension.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 14-5-28. 7 | // Copyright (c) 2014年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJExtension.h" 11 | #import 12 | 13 | @implementation UIScrollView (MJExtension) 14 | 15 | - (void)setMj_insetT:(CGFloat)mj_insetT 16 | { 17 | UIEdgeInsets inset = self.contentInset; 18 | inset.top = mj_insetT; 19 | self.contentInset = inset; 20 | } 21 | 22 | - (CGFloat)mj_insetT 23 | { 24 | return self.contentInset.top; 25 | } 26 | 27 | - (void)setMj_insetB:(CGFloat)mj_insetB 28 | { 29 | UIEdgeInsets inset = self.contentInset; 30 | inset.bottom = mj_insetB; 31 | self.contentInset = inset; 32 | } 33 | 34 | - (CGFloat)mj_insetB 35 | { 36 | return self.contentInset.bottom; 37 | } 38 | 39 | - (void)setMj_insetL:(CGFloat)mj_insetL 40 | { 41 | UIEdgeInsets inset = self.contentInset; 42 | inset.left = mj_insetL; 43 | self.contentInset = inset; 44 | } 45 | 46 | - (CGFloat)mj_insetL 47 | { 48 | return self.contentInset.left; 49 | } 50 | 51 | - (void)setMj_insetR:(CGFloat)mj_insetR 52 | { 53 | UIEdgeInsets inset = self.contentInset; 54 | inset.right = mj_insetR; 55 | self.contentInset = inset; 56 | } 57 | 58 | - (CGFloat)mj_insetR 59 | { 60 | return self.contentInset.right; 61 | } 62 | 63 | - (void)setMj_offsetX:(CGFloat)mj_offsetX 64 | { 65 | CGPoint offset = self.contentOffset; 66 | offset.x = mj_offsetX; 67 | self.contentOffset = offset; 68 | } 69 | 70 | - (CGFloat)mj_offsetX 71 | { 72 | return self.contentOffset.x; 73 | } 74 | 75 | - (void)setMj_offsetY:(CGFloat)mj_offsetY 76 | { 77 | CGPoint offset = self.contentOffset; 78 | offset.y = mj_offsetY; 79 | self.contentOffset = offset; 80 | } 81 | 82 | - (CGFloat)mj_offsetY 83 | { 84 | return self.contentOffset.y; 85 | } 86 | 87 | - (void)setMj_contentW:(CGFloat)mj_contentW 88 | { 89 | CGSize size = self.contentSize; 90 | size.width = mj_contentW; 91 | self.contentSize = size; 92 | } 93 | 94 | - (CGFloat)mj_contentW 95 | { 96 | return self.contentSize.width; 97 | } 98 | 99 | - (void)setMj_contentH:(CGFloat)mj_contentH 100 | { 101 | CGSize size = self.contentSize; 102 | size.height = mj_contentH; 103 | self.contentSize = size; 104 | } 105 | 106 | - (CGFloat)mj_contentH 107 | { 108 | return self.contentSize.height; 109 | } 110 | @end 111 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoGifFooter.h" 10 | 11 | @interface MJRefreshAutoGifFooter() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshAutoGifFooter 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)placeSubviews 78 | { 79 | [super placeSubviews]; 80 | 81 | if (self.gifView.constraints.count) return; 82 | 83 | self.gifView.frame = self.bounds; 84 | if (self.isRefreshingTitleHidden) { 85 | self.gifView.contentMode = UIViewContentModeCenter; 86 | } else { 87 | self.gifView.contentMode = UIViewContentModeRight; 88 | self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; 89 | } 90 | } 91 | 92 | - (void)setState:(MJRefreshState)state 93 | { 94 | MJRefreshCheckState 95 | 96 | // 根据状态做事情 97 | if (state == MJRefreshStateRefreshing) { 98 | NSArray *images = self.stateImages[@(state)]; 99 | if (images.count == 0) return; 100 | [self.gifView stopAnimating]; 101 | 102 | self.gifView.hidden = NO; 103 | if (images.count == 1) { // 单张图片 104 | self.gifView.image = [images lastObject]; 105 | } else { // 多张图片 106 | self.gifView.animationImages = images; 107 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 108 | [self.gifView startAnimating]; 109 | } 110 | } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 111 | [self.gifView stopAnimating]; 112 | self.gifView.hidden = YES; 113 | } 114 | } 115 | @end 116 | 117 | -------------------------------------------------------------------------------- /WYNullView/Category/UIView+HiddenEx.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+HiddenEx.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "UIView+HiddenEx.h" 10 | #import 11 | #import "NSBundle+WY.h" 12 | 13 | @implementation UIView (HiddenEx) 14 | 15 | #pragma mark - 静默视图 16 | static const void *wy_classWhitelistValueKey = &wy_classWhitelistValueKey; 17 | static const void *wy_objWhitelistValueKey = &wy_objWhitelistValueKey; 18 | 19 | - (void)setWy_classWhitelist:(NSMutableArray *)wy_classWhitelist { 20 | objc_setAssociatedObject(self, wy_classWhitelistValueKey, wy_classWhitelist, OBJC_ASSOCIATION_RETAIN); 21 | } 22 | 23 | - (NSMutableArray *)wy_classWhitelist { 24 | NSMutableArray *classWhitelist = objc_getAssociatedObject(self,wy_classWhitelistValueKey); 25 | if (!classWhitelist) { 26 | classWhitelist = [NSMutableArray array]; 27 | [self setWy_classWhitelist:classWhitelist]; 28 | NSMutableArray *whitelistInPlist = [self _loadWhitePlist]; 29 | Class class = nil; 30 | for (NSString *className in whitelistInPlist) { 31 | if (className.length) { 32 | class = NSClassFromString(className); 33 | } 34 | if (class) { 35 | [classWhitelist addObject:makeWeakReference(class)]; 36 | } 37 | } 38 | } 39 | return classWhitelist; 40 | } 41 | 42 | - (void)setWy_objWhitelist:(NSMutableArray *)wy_objWhitelist{ 43 | objc_setAssociatedObject(self, wy_objWhitelistValueKey, wy_objWhitelist, OBJC_ASSOCIATION_RETAIN); 44 | } 45 | 46 | - (NSMutableArray *)wy_objWhitelist { 47 | NSMutableArray *objWhitelist = objc_getAssociatedObject(self, wy_objWhitelistValueKey); 48 | if (!objWhitelist) { 49 | objWhitelist = [NSMutableArray array]; 50 | [self setWy_objWhitelist:objWhitelist]; 51 | } 52 | return objWhitelist; 53 | } 54 | 55 | - (void)wy_hideOtherViewAndShowView:(UIView *)view { 56 | for (UIView *subView in self.subviews) { 57 | if ([self _isInClasswhitelist:subView]) { 58 | continue; 59 | } 60 | if ([self _isInObjwhitelist:subView]) { 61 | continue; 62 | } 63 | [subView setHidden:YES]; 64 | } 65 | view.hidden = NO; 66 | } 67 | 68 | - (void)wy_showOtherViewAndHideView:(UIView *)view { 69 | for (UIView *subView in self.subviews) { 70 | if ([self _isInClasswhitelist:subView]) { // 屏蔽下拉刷新 71 | continue; 72 | } 73 | if ([self _isInObjwhitelist:subView]) { 74 | continue; 75 | } 76 | [subView setHidden:NO]; 77 | } 78 | view.hidden = YES; 79 | } 80 | 81 | #pragma mark - 私有方法 82 | - (NSMutableArray *)_loadWhitePlist { 83 | return [NSBundle wy_classWhitelistArrayM]; 84 | } 85 | 86 | - (BOOL)_isInClasswhitelist:(id)obj { 87 | BOOL flag = NO; 88 | for (WeakReference weakClass in self.wy_classWhitelist) { 89 | Class class = weakReferenceNonretainedObjectValue(weakClass); 90 | if (class) { 91 | flag = [obj isKindOfClass:weakReferenceNonretainedObjectValue(weakClass)]; 92 | } 93 | if (flag) { 94 | break; 95 | } 96 | } 97 | return flag; 98 | } 99 | 100 | - (BOOL)_isInObjwhitelist:(id)obj { 101 | BOOL flag = NO; 102 | for (WeakReference weakClass in self.wy_objWhitelist) { 103 | id whiteObj = weakReferenceNonretainedObjectValue(weakClass); 104 | if (obj == whiteObj) { 105 | flag = YES; 106 | break; 107 | } 108 | } 109 | return flag; 110 | } 111 | 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | MJRefresh 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Copyright (c) 2013-2015 WYNullView (https://github.com/WymanLyu/WYNullView) 47 | 48 | Permission is hereby granted, free of charge, to any person obtaining a copy 49 | of this software and associated documentation files (the "Software"), to deal 50 | in the Software without restriction, including without limitation the rights 51 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 52 | copies of the Software, and to permit persons to whom the Software is 53 | furnished to do so, subject to the following conditions: 54 | 55 | The above copyright notice and this permission notice shall be included in 56 | all copies or substantial portions of the Software. 57 | 58 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 62 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 63 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 64 | THE SOFTWARE. 65 | License 66 | MIT 67 | Title 68 | WYNullView 69 | Type 70 | PSGroupSpecifier 71 | 72 | 73 | FooterText 74 | Generated by CocoaPods - https://cocoapods.org 75 | Title 76 | 77 | Type 78 | PSGroupSpecifier 79 | 80 | 81 | StringsTable 82 | Acknowledgements 83 | Title 84 | Acknowledgements 85 | 86 | 87 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.h: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshComponent.h 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 刷新控件的基类 9 | 10 | #import 11 | #import "MJRefreshConst.h" 12 | #import "UIView+MJExtension.h" 13 | #import "UIScrollView+MJExtension.h" 14 | #import "UIScrollView+MJRefresh.h" 15 | #import "NSBundle+MJRefresh.h" 16 | 17 | /** 刷新控件的状态 */ 18 | typedef NS_ENUM(NSInteger, MJRefreshState) { 19 | /** 普通闲置状态 */ 20 | MJRefreshStateIdle = 1, 21 | /** 松开就可以进行刷新的状态 */ 22 | MJRefreshStatePulling, 23 | /** 正在刷新中的状态 */ 24 | MJRefreshStateRefreshing, 25 | /** 即将刷新的状态 */ 26 | MJRefreshStateWillRefresh, 27 | /** 所有数据加载完毕,没有更多的数据了 */ 28 | MJRefreshStateNoMoreData 29 | }; 30 | 31 | /** 进入刷新状态的回调 */ 32 | typedef void (^MJRefreshComponentRefreshingBlock)(); 33 | /** 开始刷新后的回调(进入刷新状态后的回调) */ 34 | typedef void (^MJRefreshComponentbeginRefreshingCompletionBlock)(); 35 | /** 结束刷新后的回调 */ 36 | typedef void (^MJRefreshComponentEndRefreshingCompletionBlock)(); 37 | 38 | /** 刷新控件的基类 */ 39 | @interface MJRefreshComponent : UIView 40 | { 41 | /** 记录scrollView刚开始的inset */ 42 | UIEdgeInsets _scrollViewOriginalInset; 43 | /** 父控件 */ 44 | __weak UIScrollView *_scrollView; 45 | } 46 | #pragma mark - 刷新回调 47 | /** 正在刷新的回调 */ 48 | @property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; 49 | /** 设置回调对象和回调方法 */ 50 | - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; 51 | 52 | /** 回调对象 */ 53 | @property (weak, nonatomic) id refreshingTarget; 54 | /** 回调方法 */ 55 | @property (assign, nonatomic) SEL refreshingAction; 56 | /** 触发回调(交给子类去调用) */ 57 | - (void)executeRefreshingCallback; 58 | 59 | #pragma mark - 刷新状态控制 60 | /** 进入刷新状态 */ 61 | - (void)beginRefreshing; 62 | - (void)beginRefreshingWithCompletionBlock:(void (^)())completionBlock; 63 | /** 开始刷新后的回调(进入刷新状态后的回调) */ 64 | @property (copy, nonatomic) MJRefreshComponentbeginRefreshingCompletionBlock beginRefreshingCompletionBlock; 65 | /** 结束刷新的回调 */ 66 | @property (copy, nonatomic) MJRefreshComponentEndRefreshingCompletionBlock endRefreshingCompletionBlock; 67 | /** 结束刷新状态 */ 68 | - (void)endRefreshing; 69 | - (void)endRefreshingWithCompletionBlock:(void (^)())completionBlock; 70 | /** 是否正在刷新 */ 71 | - (BOOL)isRefreshing; 72 | /** 刷新状态 一般交给子类内部实现 */ 73 | @property (assign, nonatomic) MJRefreshState state; 74 | 75 | #pragma mark - 交给子类去访问 76 | /** 记录scrollView刚开始的inset */ 77 | @property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; 78 | /** 父控件 */ 79 | @property (weak, nonatomic, readonly) UIScrollView *scrollView; 80 | 81 | #pragma mark - 交给子类们去实现 82 | /** 初始化 */ 83 | - (void)prepare NS_REQUIRES_SUPER; 84 | /** 摆放子控件frame */ 85 | - (void)placeSubviews NS_REQUIRES_SUPER; 86 | /** 当scrollView的contentOffset发生改变的时候调用 */ 87 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 88 | /** 当scrollView的contentSize发生改变的时候调用 */ 89 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 90 | /** 当scrollView的拖拽状态发生改变的时候调用 */ 91 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; 92 | 93 | 94 | #pragma mark - 其他 95 | /** 拉拽的百分比(交给子类重写) */ 96 | @property (assign, nonatomic) CGFloat pullingPercent; 97 | /** 根据拖拽比例自动切换透明度 */ 98 | @property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); 99 | /** 根据拖拽比例自动切换透明度 */ 100 | @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; 101 | @end 102 | 103 | @interface UILabel(MJRefresh) 104 | + (instancetype)mj_label; 105 | - (CGFloat)mj_textWith; 106 | @end 107 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WYNullView 2 | 3 | An easy way to use when view' content is empty 4 | 5 | # Overview 6 | 7 | ![](https://github.com/WymanLyu/WYNullView/blob/master/WYNullView/Images/nullTest.gif) 8 | 9 | # How to use 10 | 11 | * Installation with CocoaPods:pod 'WYNullView' 12 | 13 | * Import the main file:#import "WYNullView.h" 14 | 15 | * On the empty state show default content, then all you have to do is: 16 | 17 | ```objc 18 | if (showNullView) { // 无数据,empty data -》 show nullview 19 | [self.tableView wy_showNullView]; 20 | } else { // 有数据,data -》 hide nullview 21 | [self.tableView wy_hideNullView]; 22 | } 23 | ``` 24 | 25 | * You will be able to fully customize the content and appearance of the empty states for your application 26 | 27 | ```objc 28 | if (showNullView) { // 无数据,empty data -》 show nullview 29 | [self.tableView wy_showNullView:^UIView *(NullView *defaultNullView) { 30 | // you can do any constom operation in this block, even return a new constom UIView obj 31 | // rerurn [UIView new]; 32 | defaultNullView.desText = @"基于NullView自定义"; 33 | defaultNullView.frame = CGRectMake(10, 10, defaultNullView.frame.size.width, defaultNullView.frame.size.height); 34 | defaultNullView.backgroundColor = [UIColor cyanColor]; 35 | return defaultNullView; 36 | } heightOffset:0.0]; 37 | } else { // 有数据,data -》 hide nullview 38 | [self.tableView wy_hideNullView]; 39 | } 40 | 41 | ``` 42 | 43 | # Implementation 44 | 45 | * UIView-Category add AssociatedObject "wy_nullView": 46 | 47 | ```objc 48 | ///> 空视图 49 | @property (nonatomic, strong) UIView *wy_nullView; 50 | 51 | ``` 52 | 53 | * Looking for NullView chain: 54 | 55 | * \+ (void)wy_configGlobleNullView:(NullViewHandle)nullViewHandle 56 | * \- (void)wy_configNullView:(NullViewHandle)nullViewHandle 57 | * \- (void)wy_showNullView:(NullViewHandle)nullViewHandle heightOffset:(CGFloat)offset 58 | 59 | * NullViewHandle Type: 60 | 61 | ``` 62 | typedef UIView *(^NullViewHandle)(NullView *defaultNullView); 63 | ``` 64 | 65 | * Different methods can be used in different ways: 66 | 67 | * Global configuration 【View object whatever it is type, show the same content from "wy_configGlobleNullView" nullViewHandle return 】: 68 | 69 | ```Objc 70 | [UIView wy_configGlobleNullView:^UIView *(NullView *defaultNullView) { 71 | // return globalNullView... 72 | }]; 73 | ``` 74 | 75 | * View configuration【Once config, you can call "wy_showNullView" directly, 】 76 | 77 | 78 | ```Objc 79 | - (void)viewDidLoad { 80 | [mView wy_configNullView:^UIView *(NullView *defaultNullView) { 81 | // return nullView... 82 | }]; 83 | } 84 | - (void)func1 { 85 | ... 86 | [mView wy_showNullView]; 87 | ... 88 | } 89 | - (void)func2 { 90 | ... 91 | [mView wy_showNullView]; 92 | ... 93 | } 94 | ``` 95 | 96 | * If you have plenty of time, you can do the following【Equivalent to the above】: 97 | 98 | ```Objc 99 | 100 | - (void)func1 { 101 | ... 102 | [mView wy_showNullView:^UIView *(NullView *defaultNullView) { 103 | // return nullView... 104 | } heightOffset:0.0]]; 105 | ... 106 | } 107 | - (void)func2 { 108 | ... 109 | [mView wy_showNullView:^UIView *(NullView *defaultNullView) { 110 | // return nullView... 111 | } heightOffset:0.0]]; 112 | ... 113 | } 114 | ``` 115 | 116 | * Control special subView show/hidden 117 | 118 | * filter obj 119 | 120 | ```Objc 121 | 122 | // add objc_whitelist 123 | [[mView wy_objWhitelist] addObject:makeWeakReference(mView_subView)]; 124 | 125 | ``` 126 | * filter class 127 | 128 | ```Objc 129 | 130 | // add class_whitelist 131 | [[self.tableView wy_classWhitelist] addObject:makeWeakReference([mView_subView class])]; 132 | ``` 133 | 134 | # Hope 135 | 136 | If you think it's useful, star to me, Free to share with ideas, issue or pull requests 137 | 138 | # License 139 | 140 | MIT 141 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackGifFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackGifFooter.h" 10 | 11 | @interface MJRefreshBackGifFooter() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshBackGifFooter 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)setPullingPercent:(CGFloat)pullingPercent 78 | { 79 | [super setPullingPercent:pullingPercent]; 80 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 81 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 82 | [self.gifView stopAnimating]; 83 | NSUInteger index = images.count * pullingPercent; 84 | if (index >= images.count) index = images.count - 1; 85 | self.gifView.image = images[index]; 86 | } 87 | 88 | - (void)placeSubviews 89 | { 90 | [super placeSubviews]; 91 | 92 | if (self.gifView.constraints.count) return; 93 | 94 | self.gifView.frame = self.bounds; 95 | if (self.stateLabel.hidden) { 96 | self.gifView.contentMode = UIViewContentModeCenter; 97 | } else { 98 | self.gifView.contentMode = UIViewContentModeRight; 99 | self.gifView.mj_w = self.mj_w * 0.5 - self.labelLeftInset - self.stateLabel.mj_textWith * 0.5; 100 | } 101 | } 102 | 103 | - (void)setState:(MJRefreshState)state 104 | { 105 | MJRefreshCheckState 106 | 107 | // 根据状态做事情 108 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 109 | NSArray *images = self.stateImages[@(state)]; 110 | if (images.count == 0) return; 111 | 112 | self.gifView.hidden = NO; 113 | [self.gifView stopAnimating]; 114 | if (images.count == 1) { // 单张图片 115 | self.gifView.image = [images lastObject]; 116 | } else { // 多张图片 117 | self.gifView.animationImages = images; 118 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 119 | [self.gifView startAnimating]; 120 | } 121 | } else if (state == MJRefreshStateIdle) { 122 | self.gifView.hidden = NO; 123 | } else if (state == MJRefreshStateNoMoreData) { 124 | self.gifView.hidden = YES; 125 | } 126 | } 127 | @end 128 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackNormalFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackNormalFooter.h" 10 | #import "NSBundle+MJRefresh.h" 11 | 12 | @interface MJRefreshBackNormalFooter() 13 | { 14 | __unsafe_unretained UIImageView *_arrowView; 15 | } 16 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 17 | @end 18 | 19 | @implementation MJRefreshBackNormalFooter 20 | #pragma mark - 懒加载子控件 21 | - (UIImageView *)arrowView 22 | { 23 | if (!_arrowView) { 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | 31 | - (UIActivityIndicatorView *)loadingView 32 | { 33 | if (!_loadingView) { 34 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 35 | loadingView.hidesWhenStopped = YES; 36 | [self addSubview:_loadingView = loadingView]; 37 | } 38 | return _loadingView; 39 | } 40 | 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | #pragma mark - 重写父类的方法 49 | - (void)prepare 50 | { 51 | [super prepare]; 52 | 53 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 54 | } 55 | 56 | - (void)placeSubviews 57 | { 58 | [super placeSubviews]; 59 | 60 | // 箭头的中心点 61 | CGFloat arrowCenterX = self.mj_w * 0.5; 62 | if (!self.stateLabel.hidden) { 63 | arrowCenterX -= self.labelLeftInset + self.stateLabel.mj_textWith * 0.5; 64 | } 65 | CGFloat arrowCenterY = self.mj_h * 0.5; 66 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 67 | 68 | // 箭头 69 | if (self.arrowView.constraints.count == 0) { 70 | self.arrowView.mj_size = self.arrowView.image.size; 71 | self.arrowView.center = arrowCenter; 72 | } 73 | 74 | // 圈圈 75 | if (self.loadingView.constraints.count == 0) { 76 | self.loadingView.center = arrowCenter; 77 | } 78 | 79 | self.arrowView.tintColor = self.stateLabel.textColor; 80 | } 81 | 82 | - (void)setState:(MJRefreshState)state 83 | { 84 | MJRefreshCheckState 85 | 86 | // 根据状态做事情 87 | if (state == MJRefreshStateIdle) { 88 | if (oldState == MJRefreshStateRefreshing) { 89 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 90 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 91 | self.loadingView.alpha = 0.0; 92 | } completion:^(BOOL finished) { 93 | self.loadingView.alpha = 1.0; 94 | [self.loadingView stopAnimating]; 95 | 96 | self.arrowView.hidden = NO; 97 | }]; 98 | } else { 99 | self.arrowView.hidden = NO; 100 | [self.loadingView stopAnimating]; 101 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 102 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 103 | }]; 104 | } 105 | } else if (state == MJRefreshStatePulling) { 106 | self.arrowView.hidden = NO; 107 | [self.loadingView stopAnimating]; 108 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 109 | self.arrowView.transform = CGAffineTransformIdentity; 110 | }]; 111 | } else if (state == MJRefreshStateRefreshing) { 112 | self.arrowView.hidden = YES; 113 | [self.loadingView startAnimating]; 114 | } else if (state == MJRefreshStateNoMoreData) { 115 | self.arrowView.hidden = YES; 116 | [self.loadingView stopAnimating]; 117 | } 118 | } 119 | 120 | @end 121 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshGifHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshGifHeader.h" 10 | 11 | @interface MJRefreshGifHeader() 12 | { 13 | __unsafe_unretained UIImageView *_gifView; 14 | } 15 | /** 所有状态对应的动画图片 */ 16 | @property (strong, nonatomic) NSMutableDictionary *stateImages; 17 | /** 所有状态对应的动画时间 */ 18 | @property (strong, nonatomic) NSMutableDictionary *stateDurations; 19 | @end 20 | 21 | @implementation MJRefreshGifHeader 22 | #pragma mark - 懒加载 23 | - (UIImageView *)gifView 24 | { 25 | if (!_gifView) { 26 | UIImageView *gifView = [[UIImageView alloc] init]; 27 | [self addSubview:_gifView = gifView]; 28 | } 29 | return _gifView; 30 | } 31 | 32 | - (NSMutableDictionary *)stateImages 33 | { 34 | if (!_stateImages) { 35 | self.stateImages = [NSMutableDictionary dictionary]; 36 | } 37 | return _stateImages; 38 | } 39 | 40 | - (NSMutableDictionary *)stateDurations 41 | { 42 | if (!_stateDurations) { 43 | self.stateDurations = [NSMutableDictionary dictionary]; 44 | } 45 | return _stateDurations; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state 50 | { 51 | if (images == nil) return; 52 | 53 | self.stateImages[@(state)] = images; 54 | self.stateDurations[@(state)] = @(duration); 55 | 56 | /* 根据图片设置控件的高度 */ 57 | UIImage *image = [images firstObject]; 58 | if (image.size.height > self.mj_h) { 59 | self.mj_h = image.size.height; 60 | } 61 | } 62 | 63 | - (void)setImages:(NSArray *)images forState:(MJRefreshState)state 64 | { 65 | [self setImages:images duration:images.count * 0.1 forState:state]; 66 | } 67 | 68 | #pragma mark - 实现父类的方法 69 | - (void)prepare 70 | { 71 | [super prepare]; 72 | 73 | // 初始化间距 74 | self.labelLeftInset = 20; 75 | } 76 | 77 | - (void)setPullingPercent:(CGFloat)pullingPercent 78 | { 79 | [super setPullingPercent:pullingPercent]; 80 | NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; 81 | if (self.state != MJRefreshStateIdle || images.count == 0) return; 82 | // 停止动画 83 | [self.gifView stopAnimating]; 84 | // 设置当前需要显示的图片 85 | NSUInteger index = images.count * pullingPercent; 86 | if (index >= images.count) index = images.count - 1; 87 | self.gifView.image = images[index]; 88 | } 89 | 90 | - (void)placeSubviews 91 | { 92 | [super placeSubviews]; 93 | 94 | if (self.gifView.constraints.count) return; 95 | 96 | self.gifView.frame = self.bounds; 97 | if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { 98 | self.gifView.contentMode = UIViewContentModeCenter; 99 | } else { 100 | self.gifView.contentMode = UIViewContentModeRight; 101 | 102 | CGFloat stateWidth = self.stateLabel.mj_textWith; 103 | CGFloat timeWidth = 0.0; 104 | if (!self.lastUpdatedTimeLabel.hidden) { 105 | timeWidth = self.lastUpdatedTimeLabel.mj_textWith; 106 | } 107 | CGFloat textWidth = MAX(stateWidth, timeWidth); 108 | self.gifView.mj_w = self.mj_w * 0.5 - textWidth * 0.5 - self.labelLeftInset; 109 | } 110 | } 111 | 112 | - (void)setState:(MJRefreshState)state 113 | { 114 | MJRefreshCheckState 115 | 116 | // 根据状态做事情 117 | if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { 118 | NSArray *images = self.stateImages[@(state)]; 119 | if (images.count == 0) return; 120 | 121 | [self.gifView stopAnimating]; 122 | if (images.count == 1) { // 单张图片 123 | self.gifView.image = [images lastObject]; 124 | } else { // 多张图片 125 | self.gifView.animationImages = images; 126 | self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; 127 | [self.gifView startAnimating]; 128 | } 129 | } else if (state == MJRefreshStateIdle) { 130 | [self.gifView stopAnimating]; 131 | } 132 | } 133 | @end 134 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/Target Support Files/Pods-WYNullViewDemo/Pods-WYNullViewDemo-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1"" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | 91 | if [[ "$CONFIGURATION" == "Debug" ]]; then 92 | install_framework "$BUILT_PRODUCTS_DIR/MJRefresh/MJRefresh.framework" 93 | install_framework "$BUILT_PRODUCTS_DIR/WYNullView/WYNullView.framework" 94 | fi 95 | if [[ "$CONFIGURATION" == "Release" ]]; then 96 | install_framework "$BUILT_PRODUCTS_DIR/MJRefresh/MJRefresh.framework" 97 | install_framework "$BUILT_PRODUCTS_DIR/WYNullView/WYNullView.framework" 98 | fi 99 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 100 | wait 101 | fi 102 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshNormalHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshNormalHeader.h" 10 | #import "NSBundle+MJRefresh.h" 11 | 12 | @interface MJRefreshNormalHeader() 13 | { 14 | __unsafe_unretained UIImageView *_arrowView; 15 | } 16 | @property (weak, nonatomic) UIActivityIndicatorView *loadingView; 17 | @end 18 | 19 | @implementation MJRefreshNormalHeader 20 | #pragma mark - 懒加载子控件 21 | - (UIImageView *)arrowView 22 | { 23 | if (!_arrowView) { 24 | UIImageView *arrowView = [[UIImageView alloc] initWithImage:[NSBundle mj_arrowImage]]; 25 | [self addSubview:_arrowView = arrowView]; 26 | } 27 | return _arrowView; 28 | } 29 | 30 | - (UIActivityIndicatorView *)loadingView 31 | { 32 | if (!_loadingView) { 33 | UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; 34 | loadingView.hidesWhenStopped = YES; 35 | [self addSubview:_loadingView = loadingView]; 36 | } 37 | return _loadingView; 38 | } 39 | 40 | #pragma mark - 公共方法 41 | - (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle 42 | { 43 | _activityIndicatorViewStyle = activityIndicatorViewStyle; 44 | 45 | self.loadingView = nil; 46 | [self setNeedsLayout]; 47 | } 48 | 49 | #pragma mark - 重写父类的方法 50 | - (void)prepare 51 | { 52 | [super prepare]; 53 | 54 | self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; 55 | } 56 | 57 | - (void)placeSubviews 58 | { 59 | [super placeSubviews]; 60 | 61 | // 箭头的中心点 62 | CGFloat arrowCenterX = self.mj_w * 0.5; 63 | if (!self.stateLabel.hidden) { 64 | CGFloat stateWidth = self.stateLabel.mj_textWith; 65 | CGFloat timeWidth = 0.0; 66 | if (!self.lastUpdatedTimeLabel.hidden) { 67 | timeWidth = self.lastUpdatedTimeLabel.mj_textWith; 68 | } 69 | CGFloat textWidth = MAX(stateWidth, timeWidth); 70 | arrowCenterX -= textWidth / 2 + self.labelLeftInset; 71 | } 72 | CGFloat arrowCenterY = self.mj_h * 0.5; 73 | CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); 74 | 75 | // 箭头 76 | if (self.arrowView.constraints.count == 0) { 77 | self.arrowView.mj_size = self.arrowView.image.size; 78 | self.arrowView.center = arrowCenter; 79 | } 80 | 81 | // 圈圈 82 | if (self.loadingView.constraints.count == 0) { 83 | self.loadingView.center = arrowCenter; 84 | } 85 | 86 | self.arrowView.tintColor = self.stateLabel.textColor; 87 | } 88 | 89 | - (void)setState:(MJRefreshState)state 90 | { 91 | MJRefreshCheckState 92 | 93 | // 根据状态做事情 94 | if (state == MJRefreshStateIdle) { 95 | if (oldState == MJRefreshStateRefreshing) { 96 | self.arrowView.transform = CGAffineTransformIdentity; 97 | 98 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 99 | self.loadingView.alpha = 0.0; 100 | } completion:^(BOOL finished) { 101 | // 如果执行完动画发现不是idle状态,就直接返回,进入其他状态 102 | if (self.state != MJRefreshStateIdle) return; 103 | 104 | self.loadingView.alpha = 1.0; 105 | [self.loadingView stopAnimating]; 106 | self.arrowView.hidden = NO; 107 | }]; 108 | } else { 109 | [self.loadingView stopAnimating]; 110 | self.arrowView.hidden = NO; 111 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 112 | self.arrowView.transform = CGAffineTransformIdentity; 113 | }]; 114 | } 115 | } else if (state == MJRefreshStatePulling) { 116 | [self.loadingView stopAnimating]; 117 | self.arrowView.hidden = NO; 118 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 119 | self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); 120 | }]; 121 | } else if (state == MJRefreshStateRefreshing) { 122 | self.loadingView.alpha = 1.0; // 防止refreshing -> idle的动画完毕动作没有被执行 123 | [self.loadingView startAnimating]; 124 | self.arrowView.hidden = YES; 125 | } 126 | } 127 | @end 128 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshAutoFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshAutoFooter.h" 10 | 11 | @interface MJRefreshAutoFooter() 12 | @end 13 | 14 | @implementation MJRefreshAutoFooter 15 | 16 | #pragma mark - 初始化 17 | - (void)willMoveToSuperview:(UIView *)newSuperview 18 | { 19 | [super willMoveToSuperview:newSuperview]; 20 | 21 | if (newSuperview) { // 新的父控件 22 | if (self.hidden == NO) { 23 | self.scrollView.mj_insetB += self.mj_h; 24 | } 25 | 26 | // 设置位置 27 | self.mj_y = _scrollView.mj_contentH; 28 | } else { // 被移除了 29 | if (self.hidden == NO) { 30 | self.scrollView.mj_insetB -= self.mj_h; 31 | } 32 | } 33 | } 34 | 35 | #pragma mark - 过期方法 36 | - (void)setAppearencePercentTriggerAutoRefresh:(CGFloat)appearencePercentTriggerAutoRefresh 37 | { 38 | self.triggerAutomaticallyRefreshPercent = appearencePercentTriggerAutoRefresh; 39 | } 40 | 41 | - (CGFloat)appearencePercentTriggerAutoRefresh 42 | { 43 | return self.triggerAutomaticallyRefreshPercent; 44 | } 45 | 46 | #pragma mark - 实现父类的方法 47 | - (void)prepare 48 | { 49 | [super prepare]; 50 | 51 | // 默认底部控件100%出现时才会自动刷新 52 | self.triggerAutomaticallyRefreshPercent = 1.0; 53 | 54 | // 设置为默认状态 55 | self.automaticallyRefresh = YES; 56 | } 57 | 58 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change 59 | { 60 | [super scrollViewContentSizeDidChange:change]; 61 | 62 | // 设置位置 63 | self.mj_y = self.scrollView.mj_contentH; 64 | } 65 | 66 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 67 | { 68 | [super scrollViewContentOffsetDidChange:change]; 69 | 70 | if (self.state != MJRefreshStateIdle || !self.automaticallyRefresh || self.mj_y == 0) return; 71 | 72 | if (_scrollView.mj_insetT + _scrollView.mj_contentH > _scrollView.mj_h) { // 内容超过一个屏幕 73 | // 这里的_scrollView.mj_contentH替换掉self.mj_y更为合理 74 | if (_scrollView.mj_offsetY >= _scrollView.mj_contentH - _scrollView.mj_h + self.mj_h * self.triggerAutomaticallyRefreshPercent + _scrollView.mj_insetB - self.mj_h) { 75 | // 防止手松开时连续调用 76 | CGPoint old = [change[@"old"] CGPointValue]; 77 | CGPoint new = [change[@"new"] CGPointValue]; 78 | if (new.y <= old.y) return; 79 | 80 | // 当底部刷新控件完全出现时,才刷新 81 | [self beginRefreshing]; 82 | } 83 | } 84 | } 85 | 86 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change 87 | { 88 | [super scrollViewPanStateDidChange:change]; 89 | 90 | if (self.state != MJRefreshStateIdle) return; 91 | 92 | if (_scrollView.panGestureRecognizer.state == UIGestureRecognizerStateEnded) {// 手松开 93 | if (_scrollView.mj_insetT + _scrollView.mj_contentH <= _scrollView.mj_h) { // 不够一个屏幕 94 | if (_scrollView.mj_offsetY >= - _scrollView.mj_insetT) { // 向上拽 95 | [self beginRefreshing]; 96 | } 97 | } else { // 超出一个屏幕 98 | if (_scrollView.mj_offsetY >= _scrollView.mj_contentH + _scrollView.mj_insetB - _scrollView.mj_h) { 99 | [self beginRefreshing]; 100 | } 101 | } 102 | } 103 | } 104 | 105 | - (void)setState:(MJRefreshState)state 106 | { 107 | MJRefreshCheckState 108 | 109 | if (state == MJRefreshStateRefreshing) { 110 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 111 | [self executeRefreshingCallback]; 112 | }); 113 | } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 114 | if (MJRefreshStateRefreshing == oldState) { 115 | if (self.endRefreshingCompletionBlock) { 116 | self.endRefreshingCompletionBlock(); 117 | } 118 | } 119 | } 120 | } 121 | 122 | - (void)setHidden:(BOOL)hidden 123 | { 124 | BOOL lastHidden = self.isHidden; 125 | 126 | [super setHidden:hidden]; 127 | 128 | if (!lastHidden && hidden) { 129 | self.state = MJRefreshStateIdle; 130 | 131 | self.scrollView.mj_insetB -= self.mj_h; 132 | } else if (lastHidden && !hidden) { 133 | self.scrollView.mj_insetB += self.mj_h; 134 | 135 | // 设置位置 136 | self.mj_y = _scrollView.mj_contentH; 137 | } 138 | } 139 | @end 140 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // UIScrollView+MJRefresh.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "UIScrollView+MJRefresh.h" 11 | #import "MJRefreshHeader.h" 12 | #import "MJRefreshFooter.h" 13 | #import 14 | 15 | @implementation NSObject (MJRefresh) 16 | 17 | + (void)exchangeInstanceMethod1:(SEL)method1 method2:(SEL)method2 18 | { 19 | method_exchangeImplementations(class_getInstanceMethod(self, method1), class_getInstanceMethod(self, method2)); 20 | } 21 | 22 | + (void)exchangeClassMethod1:(SEL)method1 method2:(SEL)method2 23 | { 24 | method_exchangeImplementations(class_getClassMethod(self, method1), class_getClassMethod(self, method2)); 25 | } 26 | 27 | @end 28 | 29 | @implementation UIScrollView (MJRefresh) 30 | 31 | #pragma mark - header 32 | static const char MJRefreshHeaderKey = '\0'; 33 | - (void)setMj_header:(MJRefreshHeader *)mj_header 34 | { 35 | if (mj_header != self.mj_header) { 36 | // 删除旧的,添加新的 37 | [self.mj_header removeFromSuperview]; 38 | [self insertSubview:mj_header atIndex:0]; 39 | 40 | // 存储新的 41 | [self willChangeValueForKey:@"mj_header"]; // KVO 42 | objc_setAssociatedObject(self, &MJRefreshHeaderKey, 43 | mj_header, OBJC_ASSOCIATION_ASSIGN); 44 | [self didChangeValueForKey:@"mj_header"]; // KVO 45 | } 46 | } 47 | 48 | - (MJRefreshHeader *)mj_header 49 | { 50 | return objc_getAssociatedObject(self, &MJRefreshHeaderKey); 51 | } 52 | 53 | #pragma mark - footer 54 | static const char MJRefreshFooterKey = '\0'; 55 | - (void)setMj_footer:(MJRefreshFooter *)mj_footer 56 | { 57 | if (mj_footer != self.mj_footer) { 58 | // 删除旧的,添加新的 59 | [self.mj_footer removeFromSuperview]; 60 | [self insertSubview:mj_footer atIndex:0]; 61 | 62 | // 存储新的 63 | [self willChangeValueForKey:@"mj_footer"]; // KVO 64 | objc_setAssociatedObject(self, &MJRefreshFooterKey, 65 | mj_footer, OBJC_ASSOCIATION_ASSIGN); 66 | [self didChangeValueForKey:@"mj_footer"]; // KVO 67 | } 68 | } 69 | 70 | - (MJRefreshFooter *)mj_footer 71 | { 72 | return objc_getAssociatedObject(self, &MJRefreshFooterKey); 73 | } 74 | 75 | #pragma mark - 过期 76 | - (void)setFooter:(MJRefreshFooter *)footer 77 | { 78 | self.mj_footer = footer; 79 | } 80 | 81 | - (MJRefreshFooter *)footer 82 | { 83 | return self.mj_footer; 84 | } 85 | 86 | - (void)setHeader:(MJRefreshHeader *)header 87 | { 88 | self.mj_header = header; 89 | } 90 | 91 | - (MJRefreshHeader *)header 92 | { 93 | return self.mj_header; 94 | } 95 | 96 | #pragma mark - other 97 | - (NSInteger)mj_totalDataCount 98 | { 99 | NSInteger totalCount = 0; 100 | if ([self isKindOfClass:[UITableView class]]) { 101 | UITableView *tableView = (UITableView *)self; 102 | 103 | for (NSInteger section = 0; section "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | 3) 22 | TARGET_DEVICE_ARGS="--target-device tv" 23 | ;; 24 | *) 25 | TARGET_DEVICE_ARGS="--target-device mac" 26 | ;; 27 | esac 28 | 29 | install_resource() 30 | { 31 | if [[ "$1" = /* ]] ; then 32 | RESOURCE_PATH="$1" 33 | else 34 | RESOURCE_PATH="${PODS_ROOT}/$1" 35 | fi 36 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 37 | cat << EOM 38 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 39 | EOM 40 | exit 1 41 | fi 42 | case $RESOURCE_PATH in 43 | *.storyboard) 44 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 45 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 46 | ;; 47 | *.xib) 48 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 49 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 50 | ;; 51 | *.framework) 52 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 54 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 55 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 56 | ;; 57 | *.xcdatamodel) 58 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 59 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 60 | ;; 61 | *.xcdatamodeld) 62 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 63 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 64 | ;; 65 | *.xcmappingmodel) 66 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 67 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 68 | ;; 69 | *.xcassets) 70 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 71 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 72 | ;; 73 | *) 74 | echo "$RESOURCE_PATH" 75 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 76 | ;; 77 | esac 78 | } 79 | 80 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 83 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 84 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 85 | fi 86 | rm -f "$RESOURCES_TO_COPY" 87 | 88 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 89 | then 90 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 91 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 92 | while read line; do 93 | if [[ $line != "${PODS_ROOT}*" ]]; then 94 | XCASSET_FILES+=("$line") 95 | fi 96 | done <<<"$OTHER_XCASSETS" 97 | 98 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 99 | fi 100 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshHeader.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshHeader.h" 11 | 12 | @interface MJRefreshHeader() 13 | @property (assign, nonatomic) CGFloat insetTDelta; 14 | @end 15 | 16 | @implementation MJRefreshHeader 17 | #pragma mark - 构造方法 18 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock 19 | { 20 | MJRefreshHeader *cmp = [[self alloc] init]; 21 | cmp.refreshingBlock = refreshingBlock; 22 | return cmp; 23 | } 24 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action 25 | { 26 | MJRefreshHeader *cmp = [[self alloc] init]; 27 | [cmp setRefreshingTarget:target refreshingAction:action]; 28 | return cmp; 29 | } 30 | 31 | #pragma mark - 覆盖父类的方法 32 | - (void)prepare 33 | { 34 | [super prepare]; 35 | 36 | // 设置key 37 | self.lastUpdatedTimeKey = MJRefreshHeaderLastUpdatedTimeKey; 38 | 39 | // 设置高度 40 | self.mj_h = MJRefreshHeaderHeight; 41 | } 42 | 43 | - (void)placeSubviews 44 | { 45 | [super placeSubviews]; 46 | 47 | // 设置y值(当自己的高度发生改变了,肯定要重新调整Y值,所以放到placeSubviews方法中设置y值) 48 | self.mj_y = - self.mj_h - self.ignoredScrollViewContentInsetTop; 49 | } 50 | 51 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 52 | { 53 | [super scrollViewContentOffsetDidChange:change]; 54 | 55 | // 在刷新的refreshing状态 56 | if (self.state == MJRefreshStateRefreshing) { 57 | if (self.window == nil) return; 58 | 59 | // sectionheader停留解决 60 | CGFloat insetT = - self.scrollView.mj_offsetY > _scrollViewOriginalInset.top ? - self.scrollView.mj_offsetY : _scrollViewOriginalInset.top; 61 | insetT = insetT > self.mj_h + _scrollViewOriginalInset.top ? self.mj_h + _scrollViewOriginalInset.top : insetT; 62 | self.scrollView.mj_insetT = insetT; 63 | 64 | self.insetTDelta = _scrollViewOriginalInset.top - insetT; 65 | return; 66 | } 67 | 68 | // 跳转到下一个控制器时,contentInset可能会变 69 | _scrollViewOriginalInset = self.scrollView.contentInset; 70 | 71 | // 当前的contentOffset 72 | CGFloat offsetY = self.scrollView.mj_offsetY; 73 | // 头部控件刚好出现的offsetY 74 | CGFloat happenOffsetY = - self.scrollViewOriginalInset.top; 75 | 76 | // 如果是向上滚动到看不见头部控件,直接返回 77 | // >= -> > 78 | if (offsetY > happenOffsetY) return; 79 | 80 | // 普通 和 即将刷新 的临界点 81 | CGFloat normal2pullingOffsetY = happenOffsetY - self.mj_h; 82 | CGFloat pullingPercent = (happenOffsetY - offsetY) / self.mj_h; 83 | 84 | if (self.scrollView.isDragging) { // 如果正在拖拽 85 | self.pullingPercent = pullingPercent; 86 | if (self.state == MJRefreshStateIdle && offsetY < normal2pullingOffsetY) { 87 | // 转为即将刷新状态 88 | self.state = MJRefreshStatePulling; 89 | } else if (self.state == MJRefreshStatePulling && offsetY >= normal2pullingOffsetY) { 90 | // 转为普通状态 91 | self.state = MJRefreshStateIdle; 92 | } 93 | } else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开 94 | // 开始刷新 95 | [self beginRefreshing]; 96 | } else if (pullingPercent < 1) { 97 | self.pullingPercent = pullingPercent; 98 | } 99 | } 100 | 101 | - (void)setState:(MJRefreshState)state 102 | { 103 | MJRefreshCheckState 104 | 105 | // 根据状态做事情 106 | if (state == MJRefreshStateIdle) { 107 | if (oldState != MJRefreshStateRefreshing) return; 108 | 109 | // 保存刷新时间 110 | [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:self.lastUpdatedTimeKey]; 111 | [[NSUserDefaults standardUserDefaults] synchronize]; 112 | 113 | // 恢复inset和offset 114 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 115 | self.scrollView.mj_insetT += self.insetTDelta; 116 | 117 | // 自动调整透明度 118 | if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; 119 | } completion:^(BOOL finished) { 120 | self.pullingPercent = 0.0; 121 | 122 | if (self.endRefreshingCompletionBlock) { 123 | self.endRefreshingCompletionBlock(); 124 | } 125 | }]; 126 | } else if (state == MJRefreshStateRefreshing) { 127 | dispatch_async(dispatch_get_main_queue(), ^{ 128 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 129 | CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; 130 | // 增加滚动区域top 131 | self.scrollView.mj_insetT = top; 132 | // 设置滚动位置 133 | [self.scrollView setContentOffset:CGPointMake(0, -top) animated:NO]; 134 | } completion:^(BOOL finished) { 135 | [self executeRefreshingCallback]; 136 | }]; 137 | }); 138 | } 139 | } 140 | 141 | #pragma mark - 公共方法 142 | - (void)endRefreshing 143 | { 144 | dispatch_async(dispatch_get_main_queue(), ^{ 145 | self.state = MJRefreshStateIdle; 146 | }); 147 | } 148 | 149 | - (NSDate *)lastUpdatedTime 150 | { 151 | return [[NSUserDefaults standardUserDefaults] objectForKey:self.lastUpdatedTimeKey]; 152 | } 153 | @end 154 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshBackFooter.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshBackFooter.h" 10 | 11 | @interface MJRefreshBackFooter() 12 | @property (assign, nonatomic) NSInteger lastRefreshCount; 13 | @property (assign, nonatomic) CGFloat lastBottomDelta; 14 | @end 15 | 16 | @implementation MJRefreshBackFooter 17 | 18 | #pragma mark - 初始化 19 | - (void)willMoveToSuperview:(UIView *)newSuperview 20 | { 21 | [super willMoveToSuperview:newSuperview]; 22 | 23 | [self scrollViewContentSizeDidChange:nil]; 24 | } 25 | 26 | #pragma mark - 实现父类的方法 27 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change 28 | { 29 | [super scrollViewContentOffsetDidChange:change]; 30 | 31 | // 如果正在刷新,直接返回 32 | if (self.state == MJRefreshStateRefreshing) return; 33 | 34 | _scrollViewOriginalInset = self.scrollView.contentInset; 35 | 36 | // 当前的contentOffset 37 | CGFloat currentOffsetY = self.scrollView.mj_offsetY; 38 | // 尾部控件刚好出现的offsetY 39 | CGFloat happenOffsetY = [self happenOffsetY]; 40 | // 如果是向下滚动到看不见尾部控件,直接返回 41 | if (currentOffsetY <= happenOffsetY) return; 42 | 43 | CGFloat pullingPercent = (currentOffsetY - happenOffsetY) / self.mj_h; 44 | 45 | // 如果已全部加载,仅设置pullingPercent,然后返回 46 | if (self.state == MJRefreshStateNoMoreData) { 47 | self.pullingPercent = pullingPercent; 48 | return; 49 | } 50 | 51 | if (self.scrollView.isDragging) { 52 | self.pullingPercent = pullingPercent; 53 | // 普通 和 即将刷新 的临界点 54 | CGFloat normal2pullingOffsetY = happenOffsetY + self.mj_h; 55 | 56 | if (self.state == MJRefreshStateIdle && currentOffsetY > normal2pullingOffsetY) { 57 | // 转为即将刷新状态 58 | self.state = MJRefreshStatePulling; 59 | } else if (self.state == MJRefreshStatePulling && currentOffsetY <= normal2pullingOffsetY) { 60 | // 转为普通状态 61 | self.state = MJRefreshStateIdle; 62 | } 63 | } else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开 64 | // 开始刷新 65 | [self beginRefreshing]; 66 | } else if (pullingPercent < 1) { 67 | self.pullingPercent = pullingPercent; 68 | } 69 | } 70 | 71 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change 72 | { 73 | [super scrollViewContentSizeDidChange:change]; 74 | 75 | // 内容的高度 76 | CGFloat contentHeight = self.scrollView.mj_contentH + self.ignoredScrollViewContentInsetBottom; 77 | // 表格的高度 78 | CGFloat scrollHeight = self.scrollView.mj_h - self.scrollViewOriginalInset.top - self.scrollViewOriginalInset.bottom + self.ignoredScrollViewContentInsetBottom; 79 | // 设置位置和尺寸 80 | self.mj_y = MAX(contentHeight, scrollHeight); 81 | } 82 | 83 | - (void)setState:(MJRefreshState)state 84 | { 85 | MJRefreshCheckState 86 | 87 | // 根据状态来设置属性 88 | if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { 89 | // 刷新完毕 90 | if (MJRefreshStateRefreshing == oldState) { 91 | [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ 92 | self.scrollView.mj_insetB -= self.lastBottomDelta; 93 | 94 | // 自动调整透明度 95 | if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; 96 | } completion:^(BOOL finished) { 97 | self.pullingPercent = 0.0; 98 | 99 | if (self.endRefreshingCompletionBlock) { 100 | self.endRefreshingCompletionBlock(); 101 | } 102 | }]; 103 | } 104 | 105 | CGFloat deltaH = [self heightForContentBreakView]; 106 | // 刚刷新完毕 107 | if (MJRefreshStateRefreshing == oldState && deltaH > 0 && self.scrollView.mj_totalDataCount != self.lastRefreshCount) { 108 | self.scrollView.mj_offsetY = self.scrollView.mj_offsetY; 109 | } 110 | } else if (state == MJRefreshStateRefreshing) { 111 | // 记录刷新前的数量 112 | self.lastRefreshCount = self.scrollView.mj_totalDataCount; 113 | 114 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 115 | CGFloat bottom = self.mj_h + self.scrollViewOriginalInset.bottom; 116 | CGFloat deltaH = [self heightForContentBreakView]; 117 | if (deltaH < 0) { // 如果内容高度小于view的高度 118 | bottom -= deltaH; 119 | } 120 | self.lastBottomDelta = bottom - self.scrollView.mj_insetB; 121 | self.scrollView.mj_insetB = bottom; 122 | self.scrollView.mj_offsetY = [self happenOffsetY] + self.mj_h; 123 | } completion:^(BOOL finished) { 124 | [self executeRefreshingCallback]; 125 | }]; 126 | } 127 | } 128 | 129 | - (void)endRefreshing 130 | { 131 | dispatch_async(dispatch_get_main_queue(), ^{ 132 | self.state = MJRefreshStateIdle; 133 | }); 134 | } 135 | 136 | - (void)endRefreshingWithNoMoreData 137 | { 138 | dispatch_async(dispatch_get_main_queue(), ^{ 139 | self.state = MJRefreshStateNoMoreData; 140 | }); 141 | } 142 | #pragma mark - 私有方法 143 | #pragma mark 获得scrollView的内容 超出 view 的高度 144 | - (CGFloat)heightForContentBreakView 145 | { 146 | CGFloat h = self.scrollView.frame.size.height - self.scrollViewOriginalInset.bottom - self.scrollViewOriginalInset.top; 147 | return self.scrollView.contentSize.height - h; 148 | } 149 | 150 | #pragma mark 刚好看到上拉刷新控件时的contentOffset.y 151 | - (CGFloat)happenOffsetY 152 | { 153 | CGFloat deltaH = [self heightForContentBreakView]; 154 | if (deltaH > 0) { 155 | return deltaH - self.scrollViewOriginalInset.top; 156 | } else { 157 | return - self.scrollViewOriginalInset.top; 158 | } 159 | } 160 | @end 161 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m: -------------------------------------------------------------------------------- 1 | // 2 | // MJRefreshStateHeader.m 3 | // MJRefreshExample 4 | // 5 | // Created by MJ Lee on 15/4/24. 6 | // Copyright (c) 2015年 小码哥. All rights reserved. 7 | // 8 | 9 | #import "MJRefreshStateHeader.h" 10 | 11 | @interface MJRefreshStateHeader() 12 | { 13 | /** 显示上一次刷新时间的label */ 14 | __unsafe_unretained UILabel *_lastUpdatedTimeLabel; 15 | /** 显示刷新状态的label */ 16 | __unsafe_unretained UILabel *_stateLabel; 17 | } 18 | /** 所有状态对应的文字 */ 19 | @property (strong, nonatomic) NSMutableDictionary *stateTitles; 20 | @end 21 | 22 | @implementation MJRefreshStateHeader 23 | #pragma mark - 懒加载 24 | - (NSMutableDictionary *)stateTitles 25 | { 26 | if (!_stateTitles) { 27 | self.stateTitles = [NSMutableDictionary dictionary]; 28 | } 29 | return _stateTitles; 30 | } 31 | 32 | - (UILabel *)stateLabel 33 | { 34 | if (!_stateLabel) { 35 | [self addSubview:_stateLabel = [UILabel mj_label]]; 36 | } 37 | return _stateLabel; 38 | } 39 | 40 | - (UILabel *)lastUpdatedTimeLabel 41 | { 42 | if (!_lastUpdatedTimeLabel) { 43 | [self addSubview:_lastUpdatedTimeLabel = [UILabel mj_label]]; 44 | } 45 | return _lastUpdatedTimeLabel; 46 | } 47 | 48 | #pragma mark - 公共方法 49 | - (void)setTitle:(NSString *)title forState:(MJRefreshState)state 50 | { 51 | if (title == nil) return; 52 | self.stateTitles[@(state)] = title; 53 | self.stateLabel.text = self.stateTitles[@(self.state)]; 54 | } 55 | 56 | #pragma mark - 日历获取在9.x之后的系统使用currentCalendar会出异常。在8.0之后使用系统新API。 57 | - (NSCalendar *)currentCalendar { 58 | if ([NSCalendar respondsToSelector:@selector(calendarWithIdentifier:)]) { 59 | return [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian]; 60 | } 61 | return [NSCalendar currentCalendar]; 62 | } 63 | 64 | #pragma mark key的处理 65 | - (void)setLastUpdatedTimeKey:(NSString *)lastUpdatedTimeKey 66 | { 67 | [super setLastUpdatedTimeKey:lastUpdatedTimeKey]; 68 | 69 | // 如果label隐藏了,就不用再处理 70 | if (self.lastUpdatedTimeLabel.hidden) return; 71 | 72 | NSDate *lastUpdatedTime = [[NSUserDefaults standardUserDefaults] objectForKey:lastUpdatedTimeKey]; 73 | 74 | // 如果有block 75 | if (self.lastUpdatedTimeText) { 76 | self.lastUpdatedTimeLabel.text = self.lastUpdatedTimeText(lastUpdatedTime); 77 | return; 78 | } 79 | 80 | if (lastUpdatedTime) { 81 | // 1.获得年月日 82 | NSCalendar *calendar = [self currentCalendar]; 83 | NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour |NSCalendarUnitMinute; 84 | NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:lastUpdatedTime]; 85 | NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]]; 86 | 87 | // 2.格式化日期 88 | NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 89 | BOOL isToday = NO; 90 | if ([cmp1 day] == [cmp2 day]) { // 今天 91 | formatter.dateFormat = @" HH:mm"; 92 | isToday = YES; 93 | } else if ([cmp1 year] == [cmp2 year]) { // 今年 94 | formatter.dateFormat = @"MM-dd HH:mm"; 95 | } else { 96 | formatter.dateFormat = @"yyyy-MM-dd HH:mm"; 97 | } 98 | NSString *time = [formatter stringFromDate:lastUpdatedTime]; 99 | 100 | // 3.显示日期 101 | self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@%@", 102 | [NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText], 103 | isToday ? [NSBundle mj_localizedStringForKey:MJRefreshHeaderDateTodayText] : @"", 104 | time]; 105 | } else { 106 | self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"%@%@", 107 | [NSBundle mj_localizedStringForKey:MJRefreshHeaderLastTimeText], 108 | [NSBundle mj_localizedStringForKey:MJRefreshHeaderNoneLastDateText]]; 109 | } 110 | } 111 | 112 | #pragma mark - 覆盖父类的方法 113 | - (void)prepare 114 | { 115 | [super prepare]; 116 | 117 | // 初始化间距 118 | self.labelLeftInset = MJRefreshLabelLeftInset; 119 | 120 | // 初始化文字 121 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderIdleText] forState:MJRefreshStateIdle]; 122 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderPullingText] forState:MJRefreshStatePulling]; 123 | [self setTitle:[NSBundle mj_localizedStringForKey:MJRefreshHeaderRefreshingText] forState:MJRefreshStateRefreshing]; 124 | } 125 | 126 | - (void)placeSubviews 127 | { 128 | [super placeSubviews]; 129 | 130 | if (self.stateLabel.hidden) return; 131 | 132 | BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0; 133 | 134 | if (self.lastUpdatedTimeLabel.hidden) { 135 | // 状态 136 | if (noConstrainsOnStatusLabel) self.stateLabel.frame = self.bounds; 137 | } else { 138 | CGFloat stateLabelH = self.mj_h * 0.5; 139 | // 状态 140 | if (noConstrainsOnStatusLabel) { 141 | self.stateLabel.mj_x = 0; 142 | self.stateLabel.mj_y = 0; 143 | self.stateLabel.mj_w = self.mj_w; 144 | self.stateLabel.mj_h = stateLabelH; 145 | } 146 | 147 | // 更新时间 148 | if (self.lastUpdatedTimeLabel.constraints.count == 0) { 149 | self.lastUpdatedTimeLabel.mj_x = 0; 150 | self.lastUpdatedTimeLabel.mj_y = stateLabelH; 151 | self.lastUpdatedTimeLabel.mj_w = self.mj_w; 152 | self.lastUpdatedTimeLabel.mj_h = self.mj_h - self.lastUpdatedTimeLabel.mj_y; 153 | } 154 | } 155 | } 156 | 157 | - (void)setState:(MJRefreshState)state 158 | { 159 | MJRefreshCheckState 160 | 161 | // 设置状态文字 162 | self.stateLabel.text = self.stateTitles[@(state)]; 163 | 164 | // 重新设置key(重新显示时间) 165 | self.lastUpdatedTimeKey = self.lastUpdatedTimeKey; 166 | } 167 | @end 168 | -------------------------------------------------------------------------------- /WYNullView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint WYNullView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "WYNullView" 19 | s.version = "1.0.2" 20 | s.summary = "An easy way to use when view' content is empty" 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = "This lib has been designed in a way where you won't need to extend UIView class. You will be able to fully customize the content and appearance of the empty states for your application" 28 | 29 | s.homepage = "https://github.com/WymanLyu/WYNullView" 30 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 31 | 32 | 33 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 34 | # 35 | # Licensing your code is important. See http://choosealicense.com for more info. 36 | # CocoaPods will detect a license file if there is a named LICENSE* 37 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 38 | # 39 | 40 | s.license = "MIT" 41 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 42 | 43 | 44 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 45 | # 46 | # Specify the authors of the library, with email addresses. Email addresses 47 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 48 | # accepts just a name if you'd rather not provide an email address. 49 | # 50 | # Specify a social_media_url where others can refer to, for example a twitter 51 | # profile URL. 52 | # 53 | 54 | s.author = { "wyman" => "wyman.lyu@gmail.com" } 55 | # Or just: s.author = "wyman" 56 | # s.authors = { "wyman" => "wyman.lyu@gmail.com" } 57 | # s.social_media_url = "http://twitter.com/wyman" 58 | 59 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 60 | # 61 | # If this Pod runs only on iOS or OS X, then specify the platform and 62 | # the deployment target. You can optionally include the target after the platform. 63 | # 64 | 65 | # s.platform = :ios 66 | s.platform = :ios, "5.0" 67 | 68 | # When using multiple platforms 69 | # s.ios.deployment_target = "5.0" 70 | # s.osx.deployment_target = "10.7" 71 | # s.watchos.deployment_target = "2.0" 72 | # s.tvos.deployment_target = "9.0" 73 | 74 | 75 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 76 | # 77 | # Specify the location from where the source should be retrieved. 78 | # Supports git, hg, bzr, svn and HTTP. 79 | # 80 | 81 | s.source = { :git => "https://github.com/WymanLyu/WYNullView.git", :tag => "#{s.version}" } 82 | 83 | 84 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 85 | # 86 | # CocoaPods is smart about how it includes source code. For source files 87 | # giving a folder will include any swift, h, m, mm, c & cpp files. 88 | # For header files it will include any header in the folder. 89 | # Not including the public_header_files will make all headers public. 90 | # 91 | 92 | # s.source_files = "WYNullView", "WYNullView/**/*.{h,m}" 93 | # s.exclude_files = "WYNullView/Exclude" 94 | 95 | # s.public_header_files = "Classes/**/*.h" 96 | 97 | s.source_files = "WYNullView/WYNullView.h" 98 | s.public_header_files = "WYNullView/WYNullView.h" 99 | 100 | s.subspec 'Tool' do |tool| 101 | tool.source_files = 'WYNullView/Tool/*.{h,m}' 102 | tool.public_header_files = 'WYNullView/Tool/*.h' 103 | # tool.frameworks = 'WYNullViewTool' 104 | end 105 | 106 | s.subspec 'View' do |view| 107 | view.source_files = 'WYNullView/View/*.{h,m}' 108 | view.public_header_files = 'WYNullView/View/*.h' 109 | # view.frameworks = 'WYNullViewView' 110 | end 111 | 112 | s.subspec 'Category' do |category| 113 | category.dependency 'WYNullView/View' 114 | category.dependency 'WYNullView/Tool' 115 | 116 | category.source_files = 'WYNullView/Category/*.{h,m}' 117 | category.public_header_files = 'WYNullView/Category/*.h' 118 | # category.frameworks = 'WYNullViewCategory' 119 | end 120 | 121 | 122 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 123 | # 124 | # A list of resources included with the Pod. These are copied into the 125 | # target bundle with a build phase script. Anything else will be cleaned. 126 | # You can preserve files from being cleaned, please don't preserve 127 | # non-essential files like tests, examples and documentation. 128 | # 129 | 130 | # s.resource = "icon.png" 131 | # s.resources = "Resources/*.png" 132 | 133 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 134 | 135 | s.resources = "WYNullView/WYNullView.bundle" 136 | 137 | 138 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 139 | # 140 | # Link your library with frameworks, or libraries. Libraries do not include 141 | # the lib prefix of their name. 142 | # 143 | 144 | # s.framework = "SomeFramework" 145 | # s.frameworks = "SomeFramework", "AnotherFramework" 146 | 147 | # s.library = "iconv" 148 | # s.libraries = "iconv", "xml2" 149 | 150 | 151 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 152 | # 153 | # If your library depends on compiler flags you can set them in the xcconfig hash 154 | # where they will only apply to your library. If you depend on other Podspecs 155 | # you can include multiple dependencies to ensure it works. 156 | 157 | # s.requires_arc = true 158 | 159 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 160 | # s.dependency "JSONKit", "~> 1.4" 161 | 162 | end 163 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/WYNullViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // WYNullViewDemo 4 | // 5 | // Created by wyman on 2017/7/28. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "MJRefresh.h" 11 | #import "NSString+TextHeight.h" 12 | #import "WYNullView.h" 13 | 14 | // 15 | // 可以打开以下宏测试NullView,显示不同的操作逻辑: 16 | // 17 | // 显示空视图: --》 1.如果没有设置则此框架创建一个NullView来展示 18 | // --》 2.如果设置了【+ (void)wy_configGlobleNullView:】则以globalView展示 19 | // --》 3.如果显示前使用 【- (void)wy_configNullView:】 defaultNullView返回了view则依靠此view则依靠此view做空视图展示 20 | // --》 4.如果显示时使用 【- (void)wy_showNullView: heightOffset:】defaultNullView返回了view则依靠此view做空视图展示 21 | // 22 | // 总结:以调用show方法前最近设置的nullView为标准,类似css就近原则,一般可以在初始化是配置config,到时候只使用【- (void)wy_showNullView】即可 23 | // 24 | // 情况1:整个工程全局都是一种NULLView的样式,可以如下配置 25 | // + (void)wy_configGlobleNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle; 26 | // 27 | // 情况2:整个工程有几种NULLView的样式,可以写一个Null单例来管理nullViewHandle 28 | // 29 | // 注意:如果在defaultNullView中返回新的view则之前的addtarget失效 30 | // 31 | 32 | #define DEFAULT_NULLVIEW_TEST 33 | #define GLOBAL_NULLVIEW_TEST 34 | //#define CONFIG_NULLVIEW_TEST 35 | //#define CUSTOM_NULLVIEW_TEST 36 | 37 | @interface ViewController () 38 | 39 | @property (nonatomic, weak) UITableView *tableView; 40 | @property (nonatomic, strong) NSArray *dataSourceArray; 41 | 42 | @end 43 | 44 | @implementation ViewController 45 | 46 | #pragma mark - 模拟网络请求 47 | /// 48 | /// 模拟网络请求,依次标记为有数据和没有数据 49 | /// 50 | /// Simulate request data from NetWork, mark value empty data or full of data 51 | /// 52 | static BOOL showNullView = YES; 53 | - (void)loadFromNet { 54 | self.dataSourceArray = nil; 55 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 56 | [self dataSourceArray]; 57 | 58 | #ifdef DEFAULT_NULLVIEW_TEST 59 | if (showNullView) { // 无数据,empty data -》 show nullview 60 | [self.tableView wy_showNullView]; 61 | } else { // 有数据,data -》 hide nullview 62 | [self.tableView wy_hideNullView]; 63 | } 64 | #endif 65 | 66 | #ifdef CONFIG_NULLVIEW_TEST 67 | if (showNullView) { // 无数据,empty data -》 show nullview 68 | [self.tableView wy_showNullView]; 69 | } else { // 有数据,data -》 hide nullview 70 | [self.tableView wy_hideNullView]; 71 | } 72 | #endif 73 | 74 | #ifdef CUSTOM_NULLVIEW_TEST 75 | // 基于NullView 进行修改,可修改frame,image,text 76 | if (showNullView) { // 无数据,empty data -》 show nullview 77 | [self.tableView wy_showNullView:^UIView *(NullView *defaultNullView) { 78 | defaultNullView.desText = @"基于NullView自定义"; 79 | defaultNullView.frame = CGRectMake(10, 10, defaultNullView.frame.size.width, defaultNullView.frame.size.height); 80 | defaultNullView.backgroundColor = [UIColor cyanColor]; 81 | return defaultNullView; 82 | } heightOffset:0.0]; 83 | } else { // 有数据,data -》 hide nullview 84 | [self.tableView wy_hideNullView]; 85 | } 86 | #endif 87 | 88 | 89 | showNullView = !showNullView; 90 | [self.tableView.mj_header endRefreshing]; 91 | }); 92 | } 93 | 94 | - (void)viewDidLoad { 95 | [super viewDidLoad]; 96 | [self.tableView.mj_header beginRefreshing]; 97 | // 设置空视图的点击事件 98 | // Add target SEL for nullview click event 99 | [self.tableView wy_nullViewAddTarget:self.tableView.mj_header action:@selector(beginRefreshing)]; 100 | #ifdef CONFIG_NULLVIEW_TEST 101 | [self.tableView wy_configNullView:^UIView *(NullView *defaultNullView) { 102 | defaultNullView.desText = @"预先配置NullView"; 103 | return defaultNullView; 104 | }]; 105 | #endif 106 | 107 | #ifdef GLOBAL_NULLVIEW_TEST 108 | [UIView wy_configGlobleNullView:^UIView *(NullView *defaultNullView) { 109 | defaultNullView.desText = @"全局配置的NullView"; 110 | return defaultNullView; 111 | }]; 112 | #endif 113 | 114 | // 测试白名单 115 | // UISwitch *switch1 = [[UISwitch alloc] initWithFrame:CGRectMake(10, 60, 44, 44)]; 116 | // [self.tableView addSubview:switch1]; 117 | // UISwitch *switch2 = [[UISwitch alloc] initWithFrame:CGRectMake(10, 100, 44, 44)]; 118 | // [self.tableView addSubview:switch2]; 119 | // [[self.tableView wy_objWhitelist] addObject:makeWeakReference(switch1)]; 120 | // [[self.tableView wy_classWhitelist] addObject:makeWeakReference(NSClassFromString(@"UISwitch"))]; 121 | 122 | 123 | } 124 | 125 | #pragma mark - lazy property 126 | - (UITableView *)tableView { 127 | if (!_tableView) { 128 | UITableView *tempTableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain]; 129 | [self.view addSubview:tempTableView]; 130 | _tableView = tempTableView; 131 | _tableView.delegate = self; 132 | _tableView.dataSource = self; 133 | _tableView.mj_header = [MJRefreshStateHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadFromNet)]; 134 | } 135 | return _tableView; 136 | } 137 | 138 | - (NSArray *)dataSourceArray { 139 | if (!_dataSourceArray) { 140 | _dataSourceArray = @[@"This project is a simple example of how to use this library", 141 | @"You will be surprised", 142 | @"How easy it is use of the lib in the view content is empty", 143 | @"This lib has been designed in a way where you won't need to extend UIView class", 144 | @"You will be able to fully customize the content and appearance of the empty states for your application", 145 | @"If you think it's useful, star to me", 146 | @"Free to share with ideas, issue or pull requests"]; 147 | } 148 | return _dataSourceArray; 149 | } 150 | 151 | #pragma mark - UITableViewDataSource 152 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 153 | return self.dataSourceArray.count; 154 | } 155 | 156 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 157 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WYNullViewDemoCell"]; 158 | if (!cell) { 159 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"WYNullViewDemoCell"]; 160 | cell.textLabel.numberOfLines = 0; 161 | cell.textLabel.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width; 162 | 163 | } 164 | cell.textLabel.text = self.dataSourceArray[indexPath.row]; 165 | CGFloat h = [self.dataSourceArray[indexPath.row] wy_getHeightWithMaxWidth:[UIScreen mainScreen].bounds.size.width font:[UIFont systemFontOfSize:17.0]] + 2*20; 166 | CGFloat w = [UIScreen mainScreen].bounds.size.width; 167 | cell.textLabel.frame = CGRectMake(0, 0, w, h); 168 | return cell; 169 | } 170 | 171 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 172 | return [self.dataSourceArray[indexPath.row] wy_getHeightWithMaxWidth:[UIScreen mainScreen].bounds.size.width font:[UIFont systemFontOfSize:17.0]]+2*20; 173 | } 174 | 175 | 176 | @end 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /WYNullView/Category/UIView+WYNullView.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+WY.m 3 | // 5-20静默视图 4 | // 5 | // Created by wyman on 2017/5/20. 6 | // Copyright © 2017年 wyman. All rights reserved. 7 | // 8 | 9 | #import "UIView+WYNullView.h" 10 | #import 11 | #import "LoadingView.h" 12 | #import "GlobleNullViewRef.h" 13 | 14 | // 屏幕适配 750×1334 15 | #define fitW(w) (((w)/(750.0))*([UIScreen mainScreen].bounds.size.width)) 16 | #define fitH(h) (((h)/(1334.0))*([UIScreen mainScreen].bounds.size.height)) 17 | 18 | @implementation UIView (WYNullView) 19 | 20 | #pragma mark - 静默视图 21 | static const void *wy_nullViewValueKey = &wy_nullViewValueKey; 22 | static const void *wy_loadingViewValueKey = &wy_loadingViewValueKey; 23 | static const void *wy_loadingMaskViewValueKey = &wy_loadingMaskViewValueKey; 24 | 25 | 26 | - (void)setWy_nullView:(UIView *)wy_nullView { 27 | objc_setAssociatedObject(self, wy_nullViewValueKey, wy_nullView, OBJC_ASSOCIATION_RETAIN); 28 | } 29 | 30 | - (UIView *)wy_nullView { 31 | return objc_getAssociatedObject(self,wy_nullViewValueKey); 32 | } 33 | 34 | - (void)setWy_loadingView:(UIView *)wy_loadingView { 35 | objc_setAssociatedObject(self, wy_loadingViewValueKey, wy_loadingView, OBJC_ASSOCIATION_RETAIN); 36 | } 37 | 38 | - (UIView *)wy_loadingView { 39 | return objc_getAssociatedObject(self,wy_loadingViewValueKey); 40 | } 41 | 42 | - (void)setWy_loadingMaskView:(UIView *)wy_loadingMaskView { 43 | objc_setAssociatedObject(self, wy_loadingMaskViewValueKey, wy_loadingMaskView, OBJC_ASSOCIATION_RETAIN); 44 | } 45 | 46 | - (UIView *)wy_loadingMaskView { 47 | return objc_getAssociatedObject(self,wy_loadingMaskViewValueKey); 48 | } 49 | 50 | 51 | /// > 空视图 52 | - (void)wy_showNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle heightOffset:(CGFloat)offset { 53 | 54 | // 0.懒加载空视图 55 | if (!self.wy_nullView) { 56 | self.wy_nullView = [NullView new]; 57 | } 58 | if ([GlobleNullViewRef shareGlobleNullViewRef].globleNullViewHandle) { // 查找全局设置 59 | UIView *globalNullView = [GlobleNullViewRef shareGlobleNullViewRef].globleNullViewHandle((NullView *)self.wy_nullView); 60 | if (globalNullView) { 61 | self.wy_nullView = globalNullView; 62 | } 63 | } 64 | CGRect originRect = self.wy_nullView.frame; 65 | 66 | // 1.更新自定义的空视图 67 | if (nullViewHandle) { 68 | UIView *customNullView = nullViewHandle((NullView *)self.wy_nullView); 69 | if (customNullView != self.wy_nullView) { 70 | [self.wy_nullView removeFromSuperview]; 71 | self.wy_nullView = customNullView; 72 | } 73 | } 74 | 75 | // 2.调整位置 76 | if (CGRectEqualToRect(originRect, self.wy_nullView.frame)) { // nullViewHandle中未修改frame 77 | self.wy_nullView.frame = CGRectMake(self.frame.size.width*0.5-NULL_WIDTH*0.5, fitH(234), NULL_WIDTH, NULL_HEIGHT); 78 | self.wy_nullView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; 79 | } 80 | if (offset) { 81 | CGRect newframe = self.wy_nullView.frame; 82 | newframe.origin.y += offset; 83 | self.wy_nullView.frame = newframe; 84 | } 85 | 86 | // 3.添加到视图渲染层级 87 | if (![self.subviews containsObject:self.wy_nullView]) { 88 | [self addSubview:self.wy_nullView]; 89 | } 90 | 91 | // 4.显示到最前面 92 | if (self.subviews.lastObject != self.wy_nullView) { 93 | [self bringSubviewToFront:self.wy_nullView]; 94 | } 95 | 96 | // 5.隐藏其他视图后显示 97 | [self wy_hideOtherViewAndShowView:self.wy_nullView]; 98 | } 99 | 100 | - (void)wy_showNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle { 101 | [self wy_showNullView:nullViewHandle heightOffset:0.0]; 102 | } 103 | 104 | - (void)wy_showNullView { 105 | [self wy_showNullView:nil heightOffset:0.0]; 106 | } 107 | 108 | - (void)wy_configNullView:(UIView *(^)(NullView *defaultNullView))nullViewConfig { 109 | // 0.懒加载空视图 110 | if (!self.wy_nullView) { 111 | self.wy_nullView = [NullView new]; 112 | } 113 | // 配置空视图 114 | if (nullViewConfig) { 115 | UIView *customNullView = nullViewConfig((NullView *)self.wy_nullView); 116 | if (customNullView != self.wy_nullView) { 117 | [self.wy_nullView removeFromSuperview]; 118 | self.wy_nullView = customNullView; 119 | } 120 | } 121 | } 122 | 123 | - (void)wy_hideNullView { 124 | // 0.显示其他视图并隐藏空视图 125 | [self wy_showOtherViewAndHideView:self.wy_nullView]; 126 | } 127 | 128 | - (void)wy_nullViewAddTarget:(id)target action:(SEL)sel { 129 | // 0.懒加载空视图 130 | if (!self.wy_nullView) { 131 | self.wy_nullView = [NullView new]; 132 | } 133 | [self.wy_nullView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:target action:sel]]; 134 | } 135 | 136 | 137 | + (void)wy_configGlobleNullView:(UIView *(^)(NullView *defaultNullView))nullViewHandle { 138 | if (nullViewHandle) { 139 | NullView *defaultNullView = [NullView new]; 140 | UIView *globleDefaultView = nullViewHandle(defaultNullView); 141 | if (globleDefaultView) { // 保存起来 142 | [GlobleNullViewRef shareGlobleNullViewRef].globleNullViewHandle = nullViewHandle; 143 | } 144 | } 145 | } 146 | 147 | /// > 加载视图 148 | 149 | - (void)wy_startLodingHideOtherView { 150 | // 1.懒加载加载视图 151 | if (!self.wy_loadingView) { 152 | self.wy_loadingView = [LoadingView new]; 153 | self.wy_loadingView.frame = CGRectMake(self.frame.size.width*0.5-LOADING_WIDTH*0.5, self.frame.size.height*0.5-LOADING_HEIGHT*0.5, LOADING_WIDTH, LOADING_HEIGHT); 154 | } 155 | // 2.添加到视图渲染层级 156 | if (![self.subviews containsObject:self.wy_loadingView]) { 157 | [self addSubview:self.wy_loadingView]; 158 | } 159 | // 3.显示到最前面 160 | if (self.subviews.lastObject != self.wy_loadingView) { 161 | [self bringSubviewToFront:self.wy_loadingView]; 162 | } 163 | // 4.隐藏其他视图并显示 164 | [self wy_hideOtherViewAndShowView:self.wy_loadingView]; 165 | // 5.加载动画 166 | [(LoadingView *)self.wy_loadingView startLoading]; 167 | } 168 | 169 | - (void)wy_startLoding { 170 | // 1.懒加载加载视图 171 | if (!self.wy_loadingView) { 172 | self.wy_loadingView = [LoadingView new]; 173 | self.wy_loadingView.frame = CGRectMake(self.frame.size.width*0.5-LOADING_WIDTH*0.5, self.frame.size.height*0.5-LOADING_HEIGHT*0.5, LOADING_WIDTH, LOADING_HEIGHT); 174 | } 175 | // 2.添加到视图渲染层级 176 | if (![self.subviews containsObject:self.wy_loadingView]) { 177 | [self addSubview:self.wy_loadingView]; 178 | } 179 | // 3.显示到最前面 180 | if (self.subviews.lastObject != self.wy_loadingView) { 181 | [self bringSubviewToFront:self.wy_loadingView]; 182 | } 183 | // 4.添加mask阻止其他操作 184 | if (!self.wy_loadingMaskView) { 185 | UIView *maskView = [UIView new]; 186 | maskView.frame = self.bounds; 187 | self.wy_loadingMaskView = maskView; 188 | } 189 | if (![self.subviews containsObject:self.wy_loadingMaskView]) { 190 | [self addSubview:self.wy_loadingMaskView]; 191 | [self insertSubview:self.wy_loadingMaskView belowSubview:self.wy_loadingView]; 192 | } 193 | self.wy_loadingView.hidden = NO; 194 | 195 | // 5.加载动画 196 | [(LoadingView *)self.wy_loadingView startLoading]; 197 | } 198 | 199 | - (void)wy_stopLoding { 200 | [self wy_showOtherViewAndHideView:self.wy_loadingView]; 201 | if (self.wy_loadingMaskView) { 202 | [self.wy_loadingMaskView removeFromSuperview]; 203 | } 204 | [(LoadingView *)self.wy_loadingView stopLoading]; 205 | } 206 | 207 | @end 208 | -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.m: -------------------------------------------------------------------------------- 1 | // 代码地址: https://github.com/CoderMJLee/MJRefresh 2 | // 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 3 | // MJRefreshComponent.m 4 | // MJRefreshExample 5 | // 6 | // Created by MJ Lee on 15/3/4. 7 | // Copyright (c) 2015年 小码哥. All rights reserved. 8 | // 9 | 10 | #import "MJRefreshComponent.h" 11 | #import "MJRefreshConst.h" 12 | 13 | @interface MJRefreshComponent() 14 | @property (strong, nonatomic) UIPanGestureRecognizer *pan; 15 | @end 16 | 17 | @implementation MJRefreshComponent 18 | #pragma mark - 初始化 19 | - (instancetype)initWithFrame:(CGRect)frame 20 | { 21 | if (self = [super initWithFrame:frame]) { 22 | // 准备工作 23 | [self prepare]; 24 | 25 | // 默认是普通状态 26 | self.state = MJRefreshStateIdle; 27 | } 28 | return self; 29 | } 30 | 31 | - (void)prepare 32 | { 33 | // 基本属性 34 | self.autoresizingMask = UIViewAutoresizingFlexibleWidth; 35 | self.backgroundColor = [UIColor clearColor]; 36 | } 37 | 38 | - (void)layoutSubviews 39 | { 40 | [self placeSubviews]; 41 | 42 | [super layoutSubviews]; 43 | } 44 | 45 | - (void)placeSubviews{} 46 | 47 | - (void)willMoveToSuperview:(UIView *)newSuperview 48 | { 49 | [super willMoveToSuperview:newSuperview]; 50 | 51 | // 如果不是UIScrollView,不做任何事情 52 | if (newSuperview && ![newSuperview isKindOfClass:[UIScrollView class]]) return; 53 | 54 | // 旧的父控件移除监听 55 | [self removeObservers]; 56 | 57 | if (newSuperview) { // 新的父控件 58 | // 设置宽度 59 | self.mj_w = newSuperview.mj_w; 60 | // 设置位置 61 | self.mj_x = 0; 62 | 63 | // 记录UIScrollView 64 | _scrollView = (UIScrollView *)newSuperview; 65 | // 设置永远支持垂直弹簧效果 66 | _scrollView.alwaysBounceVertical = YES; 67 | // 记录UIScrollView最开始的contentInset 68 | _scrollViewOriginalInset = _scrollView.contentInset; 69 | 70 | // 添加监听 71 | [self addObservers]; 72 | } 73 | } 74 | 75 | - (void)drawRect:(CGRect)rect 76 | { 77 | [super drawRect:rect]; 78 | 79 | if (self.state == MJRefreshStateWillRefresh) { 80 | // 预防view还没显示出来就调用了beginRefreshing 81 | self.state = MJRefreshStateRefreshing; 82 | } 83 | } 84 | 85 | #pragma mark - KVO监听 86 | - (void)addObservers 87 | { 88 | NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld; 89 | [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentOffset options:options context:nil]; 90 | [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentSize options:options context:nil]; 91 | self.pan = self.scrollView.panGestureRecognizer; 92 | [self.pan addObserver:self forKeyPath:MJRefreshKeyPathPanState options:options context:nil]; 93 | } 94 | 95 | - (void)removeObservers 96 | { 97 | [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentOffset]; 98 | [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentSize];; 99 | [self.pan removeObserver:self forKeyPath:MJRefreshKeyPathPanState]; 100 | self.pan = nil; 101 | } 102 | 103 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 104 | { 105 | // 遇到这些情况就直接返回 106 | if (!self.userInteractionEnabled) return; 107 | 108 | // 这个就算看不见也需要处理 109 | if ([keyPath isEqualToString:MJRefreshKeyPathContentSize]) { 110 | [self scrollViewContentSizeDidChange:change]; 111 | } 112 | 113 | // 看不见 114 | if (self.hidden) return; 115 | if ([keyPath isEqualToString:MJRefreshKeyPathContentOffset]) { 116 | [self scrollViewContentOffsetDidChange:change]; 117 | } else if ([keyPath isEqualToString:MJRefreshKeyPathPanState]) { 118 | [self scrollViewPanStateDidChange:change]; 119 | } 120 | } 121 | 122 | - (void)scrollViewContentOffsetDidChange:(NSDictionary *)change{} 123 | - (void)scrollViewContentSizeDidChange:(NSDictionary *)change{} 124 | - (void)scrollViewPanStateDidChange:(NSDictionary *)change{} 125 | 126 | #pragma mark - 公共方法 127 | #pragma mark 设置回调对象和回调方法 128 | - (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action 129 | { 130 | self.refreshingTarget = target; 131 | self.refreshingAction = action; 132 | } 133 | 134 | - (void)setState:(MJRefreshState)state 135 | { 136 | _state = state; 137 | 138 | // 加入主队列的目的是等setState:方法调用完毕、设置完文字后再去布局子控件 139 | dispatch_async(dispatch_get_main_queue(), ^{ 140 | [self setNeedsLayout]; 141 | }); 142 | } 143 | 144 | #pragma mark 进入刷新状态 145 | - (void)beginRefreshing 146 | { 147 | [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ 148 | self.alpha = 1.0; 149 | }]; 150 | self.pullingPercent = 1.0; 151 | // 只要正在刷新,就完全显示 152 | if (self.window) { 153 | self.state = MJRefreshStateRefreshing; 154 | } else { 155 | // 预防正在刷新中时,调用本方法使得header inset回置失败 156 | if (self.state != MJRefreshStateRefreshing) { 157 | self.state = MJRefreshStateWillRefresh; 158 | // 刷新(预防从另一个控制器回到这个控制器的情况,回来要重新刷新一下) 159 | [self setNeedsDisplay]; 160 | } 161 | } 162 | } 163 | 164 | - (void)beginRefreshingWithCompletionBlock:(void (^)())completionBlock 165 | { 166 | self.beginRefreshingCompletionBlock = completionBlock; 167 | 168 | [self beginRefreshing]; 169 | } 170 | 171 | #pragma mark 结束刷新状态 172 | - (void)endRefreshing 173 | { 174 | self.state = MJRefreshStateIdle; 175 | } 176 | 177 | - (void)endRefreshingWithCompletionBlock:(void (^)())completionBlock 178 | { 179 | self.endRefreshingCompletionBlock = completionBlock; 180 | 181 | [self endRefreshing]; 182 | } 183 | 184 | #pragma mark 是否正在刷新 185 | - (BOOL)isRefreshing 186 | { 187 | return self.state == MJRefreshStateRefreshing || self.state == MJRefreshStateWillRefresh; 188 | } 189 | 190 | #pragma mark 自动切换透明度 191 | - (void)setAutoChangeAlpha:(BOOL)autoChangeAlpha 192 | { 193 | self.automaticallyChangeAlpha = autoChangeAlpha; 194 | } 195 | 196 | - (BOOL)isAutoChangeAlpha 197 | { 198 | return self.isAutomaticallyChangeAlpha; 199 | } 200 | 201 | - (void)setAutomaticallyChangeAlpha:(BOOL)automaticallyChangeAlpha 202 | { 203 | _automaticallyChangeAlpha = automaticallyChangeAlpha; 204 | 205 | if (self.isRefreshing) return; 206 | 207 | if (automaticallyChangeAlpha) { 208 | self.alpha = self.pullingPercent; 209 | } else { 210 | self.alpha = 1.0; 211 | } 212 | } 213 | 214 | #pragma mark 根据拖拽进度设置透明度 215 | - (void)setPullingPercent:(CGFloat)pullingPercent 216 | { 217 | _pullingPercent = pullingPercent; 218 | 219 | if (self.isRefreshing) return; 220 | 221 | if (self.isAutomaticallyChangeAlpha) { 222 | self.alpha = pullingPercent; 223 | } 224 | } 225 | 226 | #pragma mark - 内部方法 227 | - (void)executeRefreshingCallback 228 | { 229 | dispatch_async(dispatch_get_main_queue(), ^{ 230 | if (self.refreshingBlock) { 231 | self.refreshingBlock(); 232 | } 233 | if ([self.refreshingTarget respondsToSelector:self.refreshingAction]) { 234 | MJRefreshMsgSend(MJRefreshMsgTarget(self.refreshingTarget), self.refreshingAction, self); 235 | } 236 | if (self.beginRefreshingCompletionBlock) { 237 | self.beginRefreshingCompletionBlock(); 238 | } 239 | }); 240 | } 241 | @end 242 | 243 | @implementation UILabel(MJRefresh) 244 | + (instancetype)mj_label 245 | { 246 | UILabel *label = [[self alloc] init]; 247 | label.font = MJRefreshLabelFont; 248 | label.textColor = MJRefreshLabelTextColor; 249 | label.autoresizingMask = UIViewAutoresizingFlexibleWidth; 250 | label.textAlignment = NSTextAlignmentCenter; 251 | label.backgroundColor = [UIColor clearColor]; 252 | return label; 253 | } 254 | 255 | - (CGFloat)mj_textWith { 256 | CGFloat stringWidth = 0; 257 | CGSize size = CGSizeMake(MAXFLOAT, MAXFLOAT); 258 | if (self.text.length > 0) { 259 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 260 | stringWidth =[self.text 261 | boundingRectWithSize:size 262 | options:NSStringDrawingUsesLineFragmentOrigin 263 | attributes:@{NSFontAttributeName:self.font} 264 | context:nil].size.width; 265 | #else 266 | 267 | stringWidth = [self.text sizeWithFont:self.font 268 | constrainedToSize:size 269 | lineBreakMode:NSLineBreakByCharWrapping].width; 270 | #endif 271 | } 272 | return stringWidth; 273 | } 274 | @end -------------------------------------------------------------------------------- /Example/WYNullViewDemo/Pods/MJRefresh/README.md: -------------------------------------------------------------------------------- 1 | ![(logo)](http://images.cnitblog.com/blog2015/497279/201505/051004492043385.png) 2 | ## MJRefresh 3 | * An easy way to use pull-to-refresh 4 | 5 | ## Contents 6 | * Getting Started 7 | * [Features【Support what kinds of controls to refresh】](#Support what kinds of controls to refresh) 8 | * [Installation【How to use MJRefresh】](#How to use MJRefresh) 9 | * [Who's using【More than hundreds of Apps are using MJRefresh】](#>More than hundreds of Apps are using MJRefresh) 10 | * [Classes【The Class Structure Chart of MJRefresh】](#The Class Structure Chart of MJRefresh) 11 | * Comment API 12 | * [MJRefreshComponent.h](#MJRefreshComponent.h) 13 | * [MJRefreshHeader.h](#MJRefreshHeader.h) 14 | * [MJRefreshFooter.h](#MJRefreshFooter.h) 15 | * [MJRefreshAutoFooter.h](#MJRefreshAutoFooter.h) 16 | * Examples 17 | * [Reference](#Reference) 18 | * [The drop-down refresh 01-Default](#The drop-down refresh 01-Default) 19 | * [The drop-down refresh 02-Animation image](#The drop-down refresh 02-Animation image) 20 | * [The drop-down refresh 03-Hide the time](#The drop-down refresh 03-Hide the time) 21 | * [The drop-down refresh 04-Hide status and time](#The drop-down refresh 04-Hide status and time) 22 | * [The drop-down refresh 05-DIY title](#The drop-down refresh 05-DIY title) 23 | * [The drop-down refresh 06-DIY the control of refresh](#The drop-down refresh 06-DIY the control of refresh) 24 | * [The pull to refresh 01-Default](#The pull to refresh 01-Default) 25 | * [The pull to refresh 02-Animation image](#The pull to refresh 02-Animation image) 26 | * [The pull to refresh 03-Hide the title of refresh status](#The pull to refresh 03-Hide the title of refresh status) 27 | * [The pull to refresh 04-All loaded](#The pull to refresh 04-All loaded) 28 | * [The pull to refresh 05-DIY title](#The pull to refresh 05-DIY title) 29 | * [The pull to refresh 06-Hidden After loaded](#The pull to refresh 06-Hidden After loaded) 30 | * [The pull to refresh 07-Automatic back of the pull01](#上The pull to refresh 07-Automatic back of the pull01) 31 | * [The pull to refresh 08-Automatic back of the pull02](#The pull to refresh 08-Automatic back of the pull02) 32 | * [The pull to refresh 09-DIY the control of refresh(Automatic refresh)](#The pull to refresh 09-DIY the control of refresh(Automatic refresh)) 33 | * [The pull to refresh 10-DIY the control of refresh(Automatic back)](#The pull to refresh 10-DIY the control of refresh(Automatic back)) 34 | * [UICollectionView01-The pull and drop-down refresh](#UICollectionView01-The pull and drop-down refresh) 35 | * [UIWebView01-The drop-down refresh](#UIWebView01-The drop-down refresh) 36 | * [Hope](#Hope) 37 | 38 | ## Support what kinds of controls to refresh 39 | * `UIScrollView`、`UITableView`、`UICollectionView`、`UIWebView` 40 | 41 | ## How to use MJRefresh 42 | * Installation with CocoaPods:`pod 'MJRefresh'` 43 | * Manual import: 44 | * Drag All files in the `MJRefresh` folder to project 45 | * Import the main file:`#import "MJRefresh.h"` 46 | 47 | ```objc 48 | Base Custom 49 | MJRefresh.bundle MJRefresh.h 50 | MJRefreshConst.h MJRefreshConst.m 51 | UIScrollView+MJExtension.h UIScrollView+MJExtension.m 52 | UIScrollView+MJRefresh.h UIScrollView+MJRefresh.m 53 | UIView+MJExtension.h UIView+MJExtension.m 54 | ``` 55 | 56 | ## More than hundreds of Apps are using MJRefresh 57 | 58 | * More information of App can focus on:[M了个J-博客园](http://www.cnblogs.com/mjios/p/4409853.html) 59 | 60 | ## The Class Structure Chart of MJRefresh 61 | ![](http://images0.cnblogs.com/blog2015/497279/201506/132232456139177.png) 62 | - `The class of red text` in the chart:You can use them directly 63 | - The drop-down refresh control types 64 | - Normal:`MJRefreshNormalHeader` 65 | - Gif:`MJRefreshGifHeader` 66 | - The pull to refresh control types 67 | - Auto refresh 68 | - Normal:`MJRefreshAutoNormalFooter` 69 | - Gif:`MJRefreshAutoGifFooter` 70 | - Auto Back 71 | - Normal:`MJRefreshBackNormalFooter` 72 | - Gif:`MJRefreshBackGifFooter` 73 | - `The class of non-red text` in the chart:For inheritance,to use DIY the control of refresh 74 | - About how to DIY the control of refresh,You can refer the Class in below Chart
75 | 76 | 77 | ## MJRefreshComponent.h 78 | ```objc 79 | /** The Base Class of refresh control */ 80 | @interface MJRefreshComponent : UIView 81 | #pragma mark - Control the state of Refresh 82 | 83 | /** BeginRefreshing */ 84 | - (void)beginRefreshing; 85 | /** EndRefreshing */ 86 | - (void)endRefreshing; 87 | /** IsRefreshing */ 88 | - (BOOL)isRefreshing; 89 | 90 | #pragma mark - Other 91 | /** According to the drag ratio to change alpha automatically */ 92 | @property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; 93 | @end 94 | ``` 95 | 96 | ## MJRefreshHeader.h 97 | ```objc 98 | @interface MJRefreshHeader : MJRefreshComponent 99 | /** Creat header */ 100 | + (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 101 | /** Creat header */ 102 | + (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 103 | 104 | /** This key is used to storage the time that the last time of drown-down successfully */ 105 | @property (copy, nonatomic) NSString *lastUpdatedTimeKey; 106 | /** The last time of drown-down successfully */ 107 | @property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; 108 | 109 | /** Ignored scrollView contentInset top */ 110 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; 111 | @end 112 | ``` 113 | 114 | ## MJRefreshFooter.h 115 | ```objc 116 | @interface MJRefreshFooter : MJRefreshComponent 117 | /** Creat footer */ 118 | + (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; 119 | /** Creat footer */ 120 | + (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; 121 | 122 | /** NoticeNoMoreData */ 123 | - (void)noticeNoMoreData; 124 | /** ResetNoMoreData(Clear the status of NoMoreData ) */ 125 | - (void)resetNoMoreData; 126 | 127 | /** Ignored scrollView contentInset bottom */ 128 | @property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; 129 | 130 | /** Automaticlly show or hidden by the count of data(Show-have data,Hidden- no data) */ 131 | @property (assign, nonatomic) BOOL automaticallyHidden; 132 | @end 133 | ``` 134 | 135 | ## MJRefreshAutoFooter.h 136 | ```objc 137 | @interface MJRefreshAutoFooter : MJRefreshFooter 138 | /** Is Automatically Refresh(Default is Yes) */ 139 | @property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; 140 | 141 | /** 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) */ 142 | @property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; 143 | @end 144 | ``` 145 | 146 | ## Reference 147 | ```objc 148 | * Due to there are more functions of this framework,Don't write specific text describe its usage 149 | * You can directly reference examples MJTableViewController、MJCollectionViewController、MJWebViewController,More intuitive and fast. 150 | ``` 151 | 152 | 153 | ## The drop-down refresh 01-Default 154 | 155 | ```objc 156 | self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ 157 | //Call this Block When enter the refresh status automatically 158 | }]; 159 | 或 160 | // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadNewData]) 161 | self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; 162 | 163 | // Enter the refresh status immediately 164 | [self.tableView.header beginRefreshing]; 165 | ``` 166 | ![(下拉刷新01-普通)](http://images0.cnblogs.com/blog2015/497279/201506/141204343486151.gif) 167 | 168 | ## The drop-down refresh 02-Animation image 169 | ```objc 170 | // Set the callback(一Once you enter the refresh status,then call the action of target,that is call [self loadNewData]) 171 | MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; 172 | // Set the ordinary state of animated images 173 | [header setImages:idleImages forState:MJRefreshStateIdle]; 174 | // Set the pulling state of animated images(Enter the status of refreshing as soon as loosen) 175 | [header setImages:pullingImages forState:MJRefreshStatePulling]; 176 | // Set the refreshing state of animated images 177 | [header setImages:refreshingImages forState:MJRefreshStateRefreshing]; 178 | // Set header 179 | self.tableView.mj_header = header; 180 | ``` 181 | ![(下拉刷新02-动画图片)](http://images0.cnblogs.com/blog2015/497279/201506/141204402238389.gif) 182 | 183 | ## The drop-down refresh 03-Hide the time 184 | ```objc 185 | // Hide the time 186 | header.lastUpdatedTimeLabel.hidden = YES; 187 | ``` 188 | ![(下拉刷新03-隐藏时间)](http://images0.cnblogs.com/blog2015/497279/201506/141204456132944.gif) 189 | 190 | ## The drop-down refresh 04-Hide status and time 191 | ```objc 192 | // Hide the time 193 | header.lastUpdatedTimeLabel.hidden = YES; 194 | 195 | // Hide the status 196 | header.stateLabel.hidden = YES; 197 | ``` 198 | ![(下拉刷新04-隐藏状态和时间0)](http://images0.cnblogs.com/blog2015/497279/201506/141204508639539.gif) 199 | 200 | ## The drop-down refresh 05-DIY title 201 | ```objc 202 | // Set title 203 | [header setTitle:@"Pull down to refresh" forState:MJRefreshStateIdle]; 204 | [header setTitle:@"Release to refresh" forState:MJRefreshStatePulling]; 205 | [header setTitle:@"Loading ..." forState:MJRefreshStateRefreshing]; 206 | 207 | // Set font 208 | header.stateLabel.font = [UIFont systemFontOfSize:15]; 209 | header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:14]; 210 | 211 | // Set textColor 212 | header.stateLabel.textColor = [UIColor redColor]; 213 | header.lastUpdatedTimeLabel.textColor = [UIColor blueColor]; 214 | ``` 215 | ![(下拉刷新05-自定义文字)](http://images0.cnblogs.com/blog2015/497279/201506/141204563633593.gif) 216 | 217 | ## The drop-down refresh 06-DIY the control of refresh 218 | ```objc 219 | self.tableView.mj_header = [MJDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; 220 | // Implementation reference to MJDIYHeader.h和MJDIYHeader.m 221 | ``` 222 | ![(下拉刷新06-自定义刷新控件)](http://images0.cnblogs.com/blog2015/497279/201506/141205019261159.gif) 223 | 224 | ## The pull to refresh 01-Default 225 | ```objc 226 | self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ 227 | //Call this Block When enter the refresh status automatically 228 | }]; 229 | 或 230 | // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData]) 231 | self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; 232 | ``` 233 | ![(上拉刷新01-默认)](http://images0.cnblogs.com/blog2015/497279/201506/141205090047696.gif) 234 | 235 | ## The pull to refresh 02-Animation image 236 | ```objc 237 | // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData]) 238 | MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; 239 | 240 | // Set the refresh image 241 | [footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; 242 | 243 | // Set footer 244 | self.tableView.mj_footer = footer; 245 | ``` 246 | ![(上拉刷新02-动画图片)](http://images0.cnblogs.com/blog2015/497279/201506/141205141445793.gif) 247 | 248 | ## The pull to refresh 03-Hide the title of refresh status 249 | ```objc 250 | // Hide the title of refresh status 251 | footer.refreshingTitleHidden = YES; 252 | // If does have not above method,then use footer.stateLabel.hidden = YES; 253 | ``` 254 | ![(上拉刷新03-隐藏刷新状态的文字)](http://images0.cnblogs.com/blog2015/497279/201506/141205200985774.gif) 255 | 256 | ## The pull to refresh 04-All loaded 257 | ```objc 258 | //Become the status of NoMoreData 259 | [footer noticeNoMoreData]; 260 | ``` 261 | ![(上拉刷新04-全部加载完毕)](http://images0.cnblogs.com/blog2015/497279/201506/141205248634686.gif) 262 | 263 | ## The pull to refresh 05-DIY title 264 | ```objc 265 | // Set title 266 | [footer setTitle:@"Click or drag up to refresh" forState:MJRefreshStateIdle]; 267 | [footer setTitle:@"Loading more ..." forState:MJRefreshStateRefreshing]; 268 | [footer setTitle:@"No more data" forState:MJRefreshStateNoMoreData]; 269 | 270 | // Set font 271 | footer.stateLabel.font = [UIFont systemFontOfSize:17]; 272 | 273 | // Set textColor 274 | footer.stateLabel.textColor = [UIColor blueColor]; 275 | ``` 276 | ![(上拉刷新05-自定义文字)](http://images0.cnblogs.com/blog2015/497279/201506/141205295511153.gif) 277 | 278 | ## The pull to refresh 06-Hidden After loaded 279 | ```objc 280 | //Hidden current control of the pull to refresh 281 | self.tableView.mj_footer.hidden = YES; 282 | ``` 283 | ![(上拉刷新06-加载后隐藏)](http://images0.cnblogs.com/blog2015/497279/201506/141205343481821.gif) 284 | 285 | ## The pull to refresh 07-Automatic back of the pull01 286 | ```objc 287 | self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; 288 | ``` 289 | ![(上拉刷新07-自动回弹的上拉01)](http://images0.cnblogs.com/blog2015/497279/201506/141205392239231.gif) 290 | 291 | ## The pull to refresh 08-Automatic back of the pull02 292 | ```objc 293 | MJRefreshBackGifFooter *footer = [MJRefreshBackGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; 294 | 295 | // Set the normal state of the animated image 296 | [footer setImages:idleImages forState:MJRefreshStateIdle]; 297 | // Set the pulling state of animated images(Enter the status of refreshing as soon as loosen) 298 | [footer setImages:pullingImages forState:MJRefreshStatePulling]; 299 | // Set the refreshing state of animated images 300 | [footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; 301 | 302 | // Set footer 303 | self.tableView.mj_footer = footer; 304 | ``` 305 | ![(上拉刷新07-自动回弹的上拉02)](http://images0.cnblogs.com/blog2015/497279/201506/141205441443628.gif) 306 | 307 | ## The pull to refresh 09-DIY the control of refresh(Automatic refresh) 308 | ```objc 309 | self.tableView.mj_footer = [MJDIYAutoFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; 310 | // Implementation reference to MJDIYAutoFooter.h和MJDIYAutoFooter.m 311 | ``` 312 | ![(上拉刷新09-自定义刷新控件(自动刷新))](http://images0.cnblogs.com/blog2015/497279/201506/141205500195866.gif) 313 | 314 | ## The pull to refresh 10-DIY the control of refresh(Automatic back) 315 | ```objc 316 | self.tableView.mj_footer = [MJDIYBackFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; 317 | // Implementation reference to MJDIYBackFooter.h和MJDIYBackFooter.m 318 | ``` 319 | ![(上拉刷新10-自定义刷新控件(自动回弹))](http://images0.cnblogs.com/blog2015/497279/201506/141205560666819.gif) 320 | 321 | ## UICollectionView01-The pull and drop-down refresh 322 | ```objc 323 | // The drop-down refresh 324 | self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ 325 | //Call this Block When enter the refresh status automatically 326 | }]; 327 | 328 | // The pull to refresh 329 | self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ 330 | //Call this Block When enter the refresh status automatically 331 | }]; 332 | ``` 333 | ![(UICollectionView01-上下拉刷新)](http://images0.cnblogs.com/blog2015/497279/201506/141206021603758.gif) 334 | 335 | ## UIWebView01-The drop-down refresh 336 | ```objc 337 | //Add the control of The drop-down refresh 338 | self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ 339 | //Call this Block When enter the refresh status automatically 340 | }]; 341 | ``` 342 | ![(UICollectionView01-上下拉刷新)](http://images0.cnblogs.com/blog2015/497279/201506/141206080514524.gif) 343 | 344 | ## Remind 345 | * ARC 346 | * iOS>=6.0 347 | * iPhone \ iPad screen anyway 348 | 349 | ## Hope 350 | * If you find bug when used,Hope you can Issues me,Thank you or try to download the latest code of this framework to see the BUG has been fixed or not) 351 | * If you find the function is not enough when used,Hope you can Issues me,I very much to add more useful function to this framework ,Thank you ! 352 | * If you want to contribute code for MJRefresh,please Pull Requests me 353 | * If you use MJRefresh in your develop app,Hope you can go to[CocoaControls](https://www.cocoacontrols.com/controls/mjrefresh)to add the iTunes path 354 | of you app,I Will install your app,and according to the usage of many app,to be a better design and improve to MJRefresh,Thank you ! 355 | * StepO1(WeChat is just an Example,Explore“Your app name itunes”) 356 | ![(step01)](http://ww4.sinaimg.cn/mw1024/800cdf9ctw1eq0viiv5rsj20sm0ea41t.jpg) 357 | * StepO2 358 | ![(step02)](http://ww2.sinaimg.cn/mw1024/800cdf9ctw1eq0vilejxlj20tu0me7a0.jpg) 359 | * StepO3 360 | ![(step03)](http://ww1.sinaimg.cn/mw1024/800cdf9ctw1eq0viocpo5j20wc0dc0un.jpg) 361 | * StepO4 362 | ![(step04)](http://ww3.sinaimg.cn/mw1024/800cdf9ctw1eq0vir137xj20si0gewgu.jpg) 363 | --------------------------------------------------------------------------------