【代码笔记】iOS-自定义loading(IanAlert)_移动开发_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > 移动开发 > 【代码笔记】iOS-自定义loading(IanAlert)

【代码笔记】iOS-自定义loading(IanAlert)

 2017/11/22 10:04:27  陈沐夕  程序员俱乐部  我要评论(0)
  • 摘要:一,效果图。二,工程图。三,代码。ViewController.h#import<UIKit/UIKit.h>@interfaceViewController:UIViewController{//loadingUIView*backViewLoad;}@endViewController.m#import"ViewController.h"//loading#import"IanAlert.h"@interfaceViewController(
  • 标签:笔记 iOS 代码 自定义

一,效果图。

二,工程图。

三,代码。

ViewController.h

class="cnblogs_code_copy" style="font-size: 18px">复制代码
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    //loading
    UIView *backViewLoad;

}
@end
复制代码

 

ViewController.m

复制代码
#import "ViewController.h"
//loading
#import "IanAlert.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //loading
    [self addLoadingView];

}
//点击任何处显示loading
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    //loading
    backViewLoad.hidden=NO;
    [IanAlert showloading];
    [self performSelector:@selector(loadStop) withObject:nil afterDelay:2.0];
}
//停止loading
-(void)loadStop
{
    backViewLoad.hidden=YES;
    [IanAlert hideLoading];
}
#pragma -mark --loading------
-(void)addLoadingView
{
    backViewLoad=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    backViewLoad.backgroundColor=[UIColor blackColor];
    backViewLoad.alpha=0.8;
    backViewLoad.hidden=YES;
    [self.view addSubview:backViewLoad];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
复制代码
发表评论
用户名: 匿名