FMListPlaceholder
項目地址:https://github.com/yfming93/FMListPlaceholder
一個優雅的占位圖解決方案。適用于 UITableView 和 UICollectionView。
一行代碼處理空列表占位圖邏輯
0x001 與其他的同類三方庫對比的優點:
- 首次進入列表占位圖是不顯示的。只在網絡請求完成后,再次刷新列表時才處理相關邏輯;
- 簡單、高效、實用,最快一行代碼就可以集成;
- 提供更加全面豐富、高度自定義的效果;
- 可一行代碼設置一套自己項目專屬的默認方案,然后也可以在某個特殊的列表單獨二次自定義效果;
0x002 效果演示
0x003 如何使用
- CocoaPods 使用:
- 在
Podfile
文件新增pod "FMListPlaceholder"
; - 打開終端, 切換到項目文件目錄。 執行
pod install
; - 導入主頭文件:
#import <FMListPlaceholder.h>
- 在
- 手動拖入 使用:
- 下載演示工程,把
FMListPlaceholder
文件夾拖入自己項目中; - 導入主頭文件:
#import "FMListPlaceholder.h"
;
- 下載演示工程,把
一行代碼使用
_tableView.needPlaceholderView = YES; //the same as UICollectionView
或者如下自定義
自定義全局默認
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {[FMListPlaceholder fm_defaultBackgroundColor:UIColor.whiteColor coverName:@"xxx" tips:@"Sorroy,nil here!" tipsTextColor:UIColor.grayColor tipsFont:[UIFont systemFontOfSize:16] coverSize:CGSizeZero coverCenterYOffset:-30 coverSpaceToTips:10];return YES;
}
0x004 自定義
自定義某個特殊列表
?根據自己需求自行調用如下某些接口設置,UITableView 和 UICollectionView 接口相同。
[_tableView fm_emptyCoverName:@"fm_placeholder_nil" emptyTips:@" "];
[_tableView fm_backgroundColor:[UIColor colorWithRed:0.91 green:0.90 blue:0.90 alpha:1.00] tipsTextColor:UIColor.redColor tipsFont:nil];
[_tableView fm_coverCenterYOffset:-80 coverSize:CGSizeMake(90, 120) coverSpaceToTips:20];
// the same as UICollectionView
點擊刷新邏輯
(如果需要點擊刷新邏輯,可實現如下 block)
_tableView.reloadBlock = ^(UIScrollView *listView) {// Reload Handle is Here!// [listView.mj_header beginRefreshing]; // reloadData
};
更加詳細請見演示工程
0x005 希望
如果您在使用過程中有任何疑問或想要更多界面進行自定義,您可以發給我!
- 如果您想參與本項目的維護或具有良好的設計風格,歡迎拉動請求!
- 如果您在使用時有任何問題,請與我聯系。
- 博客網站: www.yfmingo.cn
- 郵箱: yfmingo@163.com.
- 博客網站: www.yfmingo.cn
希望能夠共同完善這個項目,讓它變得更強大,能夠滿足大多數用戶的需求!
0x006 QQ 群
0x007 要求
- iOS 9.0 or later
- Xcode 9.0 or later
0x008 許可證
All source code is licensed under the MIT License.