123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // NoResultView.m
- // 乐销
- //
- // Created by mengxi on 17/1/19.
- // Copyright © 2017年 ping. All rights reserved.
- //
- #import "NoResultView.h"
- @implementation NoResultView
- #pragma mark 懒加载
- - (UILabel *)labelTitle{
- if (_labelTitle == nil) {
- _labelTitle = [UILabel new];
- [GlobalMethod setLabel:_labelTitle widthLimit:0 numLines:0 fontNum:F(14) textColor:COLOR_999 text:@""];
- }
- return _labelTitle;
- }
- - (UIView *)lineTop{
- if (!_lineTop) {
- _lineTop = [UIView new];
- _lineTop.frame = CGRectMake(0, 0, SCREEN_WIDTH, 0);
- _lineTop.backgroundColor = COLOR_BACKGROUND;
- }
- return _lineTop;
- }
- - (UIImageView *)ivNoResult{
- if (!_ivNoResult) {
- _ivNoResult = [UIImageView new];
- _ivNoResult.backgroundColor = [UIColor whiteColor];
- }
- return _ivNoResult;
- }
- #pragma mark 初始化
- - (instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
- [self addSubView];
- }
- return self;
- }
- //添加subview
- - (void)addSubView{
- self.backgroundColor = [UIColor whiteColor];
- [self addSubview:self.labelTitle];
- [self addSubview:self.lineTop];
- [self addSubview:self.ivNoResult];
- }
- #pragma mark show
- - (void)showInView:(UIView *)viewShow frame:(CGRect)frame{
- self.frame = frame;
- [self resetView];
- [viewShow addSubview:self];
- }
- #pragma mark 创建
- + (instancetype)initWithFrame:(CGRect)frame{
- NoResultView * view = [NoResultView new];
- view.frame = frame;
- [view resetView];
- return view;
- }
- #pragma mark 刷新view
- - (void)resetView{
- [self removeSubViewWithTag:TAG_LINE];//移除线
- //刷新view
- self.lineTop.top = 0;
- self.lineTop.width = self.width;
-
- self.ivNoResult.image = [UIImage imageNamed:@"nocontain"];
- self.ivNoResult.width = W(115);
- self.ivNoResult.height = W(91);
- self.ivNoResult.centerXTop = XY(self.width / 2, W(55));
- [self.labelTitle fitTitle:@"暂无数据" variable:0];
- self.labelTitle.centerXTop = XY(self.width / 2,self.ivNoResult.bottom + W(15));
- }
- //reset with image
- - (void)resetWithImageName:(NSString *)imageName{
- if (!isStr(imageName)) return;
- self.ivNoResult.image = [UIImage imageNamed:imageName];
- self.labelTitle.hidden = true;
- self.ivNoResult.hidden = false;
- }
- @end
|