TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Aug 2017 |
Maintained by wyman.
An easy way to use when view' content is empty
Installation with CocoaPods:pod 'WYNullView'
Import the main file:#import "WYNullView.h"
On the empty state show default content, then all you have to do is:
if (showNullView) { // 无数据,empty data -》 show nullview
[self.tableView wy_showNullView];
} else { // 有数据,data -》 hide nullview
[self.tableView wy_hideNullView];
}
if (showNullView) { // 无数据,empty data -》 show nullview
[self.tableView wy_showNullView:^UIView *(NullView *defaultNullView) {
// you can do any constom operation in this block, even return a new constom UIView obj
// rerurn [UIView new];
defaultNullView.desText = @"基于NullView自定义";
defaultNullView.frame = CGRectMake(10, 10, defaultNullView.frame.size.width, defaultNullView.frame.size.height);
defaultNullView.backgroundColor = [UIColor cyanColor];
return defaultNullView;
} heightOffset:0.0];
} else { // 有数据,data -》 hide nullview
[self.tableView wy_hideNullView];
}
///> 空视图
@property (nonatomic, strong) UIView *wy_nullView;
Looking for NullView chain:
NullViewHandle Type:
typedef UIView *(^NullViewHandle)(NullView *defaultNullView);
Different methods can be used in different ways:
[UIView wy_configGlobleNullView:^UIView *(NullView *defaultNullView) {
// return globalNullView...
}];
- (void)viewDidLoad {
[mView wy_configNullView:^UIView *(NullView *defaultNullView) {
// return nullView...
}];
}
- (void)func1 {
...
[mView wy_showNullView];
...
}
- (void)func2 {
...
[mView wy_showNullView];
...
}
- (void)func1 {
...
[mView wy_showNullView:^UIView *(NullView *defaultNullView) {
// return nullView...
} heightOffset:0.0]];
...
}
- (void)func2 {
...
[mView wy_showNullView:^UIView *(NullView *defaultNullView) {
// return nullView...
} heightOffset:0.0]];
...
}
Control special subView show/hidden
// add objc_whitelist
[[mView wy_objWhitelist] addObject:makeWeakReference(mView_subView)];
// add class_whitelist
[[self.tableView wy_classWhitelist] addObject:makeWeakReference([mView_subView class])];
If you think it's useful, star to me, Free to share with ideas, issue or pull requests
MIT