ios無數(shù)據(jù)展示

//NoDataView.h

#import

@interfaceNoDataView :UIView

@property (weak, nonatomic) UIView *contentView;

@property (weak, nonatomic) UIImageView *noDataIv;

@property (weak, nonatomic) UILabel *noDataLabel;

@end


//? NoDataView.m

#import "NoDataView.h"

@implementation NoDataView

- (instancetype) initWithFrame:(CGRect)frame {

? ? if?(self= [super?initWithFrame:frame]) ?{

? ? ? ? self.backgroundColor = [UIColor clearColor];

? ? ? ? [self?initUI];

? ? }

? ? return self;

}

- (void) initUI {

? ? [_noDataIv removeFromSuperview];

? ? [_noDataLabel removeFromSuperview];

? ? [_contentView removeFromSuperview];


? ? UIView *noDataView = [[UIView alloc] init];

? ? noDataView.frame =?self.bounds;

? ? noDataView.backgroundColor = [UIColor whiteColor];

? ? self.contentView = noDataView;

? ? [self?addSubview:noDataView];


? ? UIImage *noData = [UIImage imageNamed:@"no_record"];

? ? UIImageView *noDataImage = [[UIImageView alloc] initWithImage:noData];

? ? [noDataView addSubview:noDataImage];

? ? noDataImage.frame = CGRectMake(0, (self.height - noData.size.height-kSize(18) -20)/2.0, kScreenW, noData.size.height);

? ? //noDataImage.hidden = YES;

? ? noDataImage.contentMode = UIViewContentModeCenter;

? ? self.noDataIv= noDataImage;


? ? UILabel *noDataLabel = [UILabel new];

? ? [noDataView addSubview:noDataLabel];

? ? noDataLabel.frame = CGRectMake(0, ?noDataImage.bottom + kSize(18), kScreenW, 20);

? ? //noDataLabel.hidden = YES;

? ? noDataLabel.text = @"暫無數(shù)據(jù)";

? ? noDataLabel.textColor = TEXTCOLOR;

? ? noDataLabel.font = MEDIUMFONT;

? ? noDataLabel.textAlignment = NSTextAlignmentCenter;


? ? self.noDataLabel= noDataLabel;

}

@end


//使用

- (void) showTotalPowerNoDataView:(NSString*)text {

? ? _totalPowerView.hidden = YES;

? ? if? (_totalPowerNoDataView == nil) ?{

? ? ? ? _totalPowerNoDataView = [[NoDataView alloc] initWithFrame:_totalPowerView.frame];

? ? ? ? [_contentView addSubview:_totalPowerNoDataView];

? ? }

? ? _totalPowerNoDataView.noDataLabel.text = text;

? ? _totalPowerNoDataView.hidden = NO;

}

- (void) hideTotalPowerNoDataView {

? ? _totalPowerView.hidden = NO;

? ? _totalPowerNoDataView.hidden = YES;

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市棠笑,隨后出現(xiàn)的幾起案子握牧,更是在濱河造成了極大的恐慌谍珊,老刑警劉巖单料,帶你破解...
    沈念sama閱讀 212,599評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件艇拍,死亡現(xiàn)場(chǎng)離奇詭異眠蚂,居然都是意外死亡私爷,警方通過查閱死者的電腦和手機(jī)雾棺,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,629評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來当犯,“玉大人垢村,你說我怎么就攤上這事『课溃” “怎么了嘉栓?”我有些...
    開封第一講書人閱讀 158,084評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長拓诸。 經(jīng)常有香客問我侵佃,道長,這世上最難降的妖魔是什么奠支? 我笑而不...
    開封第一講書人閱讀 56,708評(píng)論 1 284
  • 正文 為了忘掉前任馋辈,我火速辦了婚禮,結(jié)果婚禮上倍谜,老公的妹妹穿的比我還像新娘迈螟。我一直安慰自己叉抡,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,813評(píng)論 6 386
  • 文/花漫 我一把揭開白布答毫。 她就那樣靜靜地躺著褥民,像睡著了一般。 火紅的嫁衣襯著肌膚如雪洗搂。 梳的紋絲不亂的頭發(fā)上消返,一...
    開封第一講書人閱讀 50,021評(píng)論 1 291
  • 那天,我揣著相機(jī)與錄音耘拇,去河邊找鬼撵颊。 笑死,一個(gè)胖子當(dāng)著我的面吹牛惫叛,可吹牛的內(nèi)容都是我干的倡勇。 我是一名探鬼主播,決...
    沈念sama閱讀 39,120評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼挣棕,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼译隘!你這毒婦竟也來了亲桥?” 一聲冷哼從身側(cè)響起洛心,我...
    開封第一講書人閱讀 37,866評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎题篷,沒想到半個(gè)月后词身,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,308評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡番枚,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,633評(píng)論 2 327
  • 正文 我和宋清朗相戀三年法严,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片葫笼。...
    茶點(diǎn)故事閱讀 38,768評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡深啤,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出路星,到底是詐尸還是另有隱情溯街,我是刑警寧澤,帶...
    沈念sama閱讀 34,461評(píng)論 4 333
  • 正文 年R本政府宣布洋丐,位于F島的核電站呈昔,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏友绝。R本人自食惡果不足惜堤尾,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,094評(píng)論 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望迁客。 院中可真熱鬧郭宝,春花似錦辞槐、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,850評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽械筛。三九已至众弓,卻和暖如春掂咒,著一層夾襖步出監(jiān)牢的瞬間竣贪,已是汗流浹背扒吁。 一陣腳步聲響...
    開封第一講書人閱讀 32,082評(píng)論 1 267
  • 我被黑心中介騙來泰國打工灌灾, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留遇骑,地道東北人恒削。 一個(gè)月前我還...
    沈念sama閱讀 46,571評(píng)論 2 362
  • 正文 我出身青樓棉浸,卻偏偏與公主長得像怀薛,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子迷郑,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,666評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容