1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // UITableView+SPSBDefault.m
- // 我的社保
- //
- // Created by shanp on 2021/4/21.
- //
- #import "UITableView+SPSBDefault.h"
- #import "SPSBNetworkManager.h"
- #import "UIView+SPSBDefault.h"
- #import <JXHLayout.h>
- #import "SPSBConstantProfile.h"
- #import <JXHViewMeasure.h>
- @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
|