// // UITableView+SPSBDefault.m // 我的社保 // // Created by shanp on 2021/4/21. // #import "UITableView+SPSBDefault.h" #import "SPSBNetworkManager.h" #import "UIView+SPSBDefault.h" #import #import "SPSBConstantProfile.h" #import @implementation UITableView (SPSBDefault) - (void)setDefaultFootViewWithError:(nullable NSError *)error image:(nullable UIImage *)image height:(CGFloat)height action:(void(^_Nullable)(void))action { SPSBNetworkDataDefault type; if (error) { if (error.code == SPSBNetworkErrorCodeNetwrokMiss) { type = SPSBNetworkDataDefaultMissNetwork; } else { type = SPSBNetworkDataDefaultMissData; } } else { type = SPSBNetworkDataDefaultNoData; } UIView *defaultView = [self defultViewWithType:type image:image action:action]; CGFloat defaultViewHeight = [defaultView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height * (SPSBDefaultViewCenterYOffsetProportion * 2 + 1); if (defaultViewHeight > height) { height = defaultViewHeight; } UIView *footView = [[UIView alloc] initWithFrame:(CGRect){CGPointZero, (CGSize){jxh_viewWidth(self), height}}]; footView.backgroundColor = self.backgroundColor; [footView addSubview:defaultView]; [defaultView makeConstraints:^(JXHConstraintMaker *make) { make.leading.and.trailing.equalTo(0); make.height.equalTo(defaultView.width); make.centerY.equalTo(footView).offset(-height * SPSBDefaultViewCenterYOffsetProportion); }]; self.tableFooterView = footView; } - (void)removeDefaultFootView { self.tableFooterView = nil; } @end