WyhShowEmpty 1.0.3

WyhShowEmpty 1.0.3

wyh 维护。



  • wyh

WyhShowEmpty

在任何视图中快速显示占位符或空UI,便于支持在服务API响应时刷新UI。

example

Gif : http://www.jianshu.com/p/34ffaa883806

CocoaPods

pod search WyhShowEmpty

代码

1. 数据源为空时显示空UI。

    [self wyh_showEmptyMsg:@"No data" dataCount:self.dataSource];

2. 显示不同的UI的自定义样式。

    WyhEmptyStyle *style = [[WyhEmptyStyle alloc]init];
    style.tipText = @"Service down!";
    style.tipTextColor = [UIColor brownColor];
    style.btnTipText = @"Disappear";
    style.imageConfig.type = GifImgLocalUrl;
    style.refreshStyle = RefreshClickOnBtnStyle;
    style.btnWidth = 100;
    style.btnHeight = 100;
    style.btnLayerCornerRadius = 50;
    style.btnLayerBorderColor = [UIColor redColor];

    [self wyh_showWithStyle:style];

3. 在每次服务请求中显示空UI,并在每次响应中刷新UI。因此,如果响应数据为空,则会显示空视图。

-(void)loadNetWork{

    [[AFHTTPSessionManager manager] POST:url parameters:body progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject[@"code"] isEqualToNumber:@0]) {

            dispatch_async(dispatch_get_main_queue(), ^{
            [self.tableView reloadData];
            // suc resp:
            [self wyh_showEmptyMsg:@"No new data." dataCount:self.dataSource];
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        // failure resp:
        [self wyh_showEmptyMsg:@"Service disabled!" dataCount:0 isHasBtn:YES Handler:^{
        [self loadNetWork];
      }];
    }];

}

联系我

简书:http://www.jianshu.com/u/b76e3853ae0b

GitHub:https://github.com/XiaoWuTongZhi/WyhShowEmpty

QQ邮箱: [email protected]