69 lines
1.9 KiB
Objective-C
69 lines
1.9 KiB
Objective-C
//
|
|
// MyHud.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 15/12/4.
|
|
// Copyright © 2015年 imac. All rights reserved.
|
|
//
|
|
|
|
#import "MyHud.h"
|
|
|
|
@implementation MyHud
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self=[super initWithFrame:frame];
|
|
if (self) {
|
|
self.backgroundColor=[UIColor clearColor];;
|
|
_hudActivityView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:
|
|
UIActivityIndicatorViewStyleWhite];
|
|
_hudActivityView.frame=CGRectMake(kScreenSize.width/2-15,30,30, 30);
|
|
|
|
[self addSubview:_hudActivityView];
|
|
_hudLabel=[[UILabel alloc]init];
|
|
_hudLabel.frame=CGRectMake(kScreenSize.width/2-50,50, 100,30);
|
|
_hudLabel.text=@"loading...";
|
|
_hudLabel.textColor=[UIColor whiteColor];
|
|
_hudLabel.textAlignment=NSTextAlignmentCenter;
|
|
[self addSubview:_hudLabel];
|
|
}
|
|
|
|
return self;
|
|
}
|
|
-(void)hidmyHud{
|
|
[_hudActivityView stopAnimating];
|
|
[self removeFromSuperview];
|
|
|
|
}
|
|
-(void)myhudstart{
|
|
|
|
[_hudActivityView startAnimating];
|
|
|
|
}
|
|
-(void)myhudtimeOut{
|
|
_myHudTimer=[NSTimer scheduledTimerWithTimeInterval:12.0 target:self selector:@selector(hudTimeout) userInfo:nil repeats:NO];
|
|
}
|
|
|
|
-(void)hudTimeout{
|
|
if (_hudActivityView.isAnimating) {
|
|
[_hudActivityView stopAnimating];
|
|
[self showTitle:@"" messsage:@"请下拉刷新重试"];
|
|
[self removeFromSuperview];
|
|
}else{
|
|
return;
|
|
}
|
|
|
|
}
|
|
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
|
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
|
NSTimeInterval dismissSeconds=1.0;
|
|
[alert show];
|
|
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:dismissSeconds];
|
|
|
|
}
|
|
-(void)dismissAlert:(UIAlertView*)alertView{
|
|
|
|
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
|
|
}
|
|
|
|
@end
|