iOS-图书管理系统

 // 判断程序是否第一次打开
NSUserDefaults *TimeOfBootCount = [NSUserDefaults standardUserDefaults];
if (![TimeOfBootCount valueForKey:@"firstLaunch"])
    {
        [TimeOfBootCount setBool:YES forKey:@"firstLaunch"];
        ViewController *v1 = [[ViewController alloc]init];
    self.window.rootViewController = v1;
        NSLog(@"第一次启动");
        
    }
    else
        
    {
        NextViewController *next1 = [[NextViewController alloc]init];
        self.window.rootViewController = next1;
        NSLog(@"不是第一次启动");
        }
[self.window makeKeyAndVisible];
    NSLog(@"启动成功");


iOS-图书管理系统_第1张图片
屏幕快照 2017-11-23 下午1.06.01.png

#import "ViewController.h"
#import "NextViewController.h"
#import "AppDelegate.h"
@interface ViewController ()
{
    // 创建滚动视图
    UIScrollView *theScroll;
    // 创建页码视图
    UIPageControl *thePage;
    // 创建图片的数组
    NSArray *theArr;
    // 创建整形类
    NSInteger teg;
    // 创建计时器
    NSTimer *theTime;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 获取当前屏幕的宽
    float width  = self.view.frame.size.width;
    float height = self.view.frame.size.height;
    // 初始化滚动视图
    theScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, width, height)];
    float X = 0.0;
    for (int i =0; i<4; i++)
        
    {
        
        // 创建图片视图
        
        UIImageView *theImg = [[UIImageView alloc]initWithFrame:CGRectMake(X, 0, width, height)];
        
        // 将图片添加带数组中
        
        theArr = @[[UIImage imageNamed:@"ww"],[UIImage imageNamed:@"Y1"],[UIImage imageNamed:@"Y2"],[UIImage imageNamed:@"Y3"]];
        
        // 将图片与数据联系
        
        theImg.image = theArr[i];
        
        // 将图片添加到滚动视图上
        
        [theScroll addSubview:theImg];
        
        // X依次递增
        
        X += width;
        
    }
    // 设置滚动视图内容大小
    
    theScroll.contentSize = CGSizeMake(width *4, height);
    
    // 设置是否按页滚动
    
    theScroll.pagingEnabled = YES;
    
    // 隐藏滚动条
    
    theScroll.showsHorizontalScrollIndicator = NO;
    
    // 设置代理
    
    theScroll.delegate = self;
    
    // 创建页码
    
    thePage = [[UIPageControl alloc]initWithFrame:CGRectMake(width / 2-50, 570, 100, 30)];
    
    // 清除页码的背景颜色
    
    thePage.backgroundColor = [UIColor clearColor];
    
    // 设置当前页码的颜色
    
    thePage.currentPageIndicatorTintColor = [UIColor blackColor];
    
    // 设置页码的颜色
    
    thePage.pageIndicatorTintColor = [UIColor redColor];
    
    // 设置页码的个数
    thePage.numberOfPages = 4;
    
    // 设置页码的起始页码
    
    thePage.currentPage = 0;
    
    // 添加到视图上
    
    // 先添加滚动视图
    
    [self.view addSubview:theScroll];
    
    // 再添加页码视图
    
    [self.view addSubview:thePage];
    
    // 使用整形变量接受页码当前的页码
    
    teg = thePage.currentPage;
    
    // 创建定时器
    
    theTime = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(scroll) userInfo:nil repeats:YES];

}
// 定时器的方法

- (void)scroll

{
    
    teg ++;
    
    if (teg >= theArr.count)
        
    {
        
        teg = 0;
        
    }
    
    // 设置滚动视图的内容偏移量
    
    [theScroll setContentOffset:CGPointMake(teg *self.view.frame.size.width, 0) animated:YES];
    
}

// 滚动视图的代理方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{
    
    CGPoint point = theScroll.contentOffset;
    
    thePage.currentPage = point.x/scrollView.frame.size.width;
    
    // 创建按钮
    
    UIButton *theBtn = [[UIButton alloc]init];
    
    if (thePage.currentPage == 3)
        
    {
        
        [theTime setFireDate:[NSDate distantFuture]];
        
        // 当滚动到最后一张图片的时候出现按钮
        
        // 设置按钮位置 z
        
        theBtn.frame = CGRectMake(230, 607, 100, 40);
        
        // 设置按钮内容
        
        [theBtn setTitle:@"立即体验" forState:UIControlStateNormal];
        
        // 设置按钮背景颜色
        
        theBtn.backgroundColor = [UIColor redColor];
        
        // 设置按钮响应事件
        
        [theBtn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
        
        // 添加到视图上 B
        
        [self.view addSubview:theBtn];
    }
}
// 按钮方法
- (void)click
{
    NextViewController *next = [[NextViewController alloc]init];
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    app.window.rootViewController = next;
}


iOS-图书管理系统_第2张图片
屏幕快照 2017-11-23 下午1.11.28.png
iOS-图书管理系统_第3张图片
屏幕快照 2017-11-23 下午1.11.37.png
iOS-图书管理系统_第4张图片
屏幕快照 2017-11-23 下午1.11.47.png
 MyViewController* my = [[MyViewController alloc]init];
    UINavigationController* myNvc = [[UINavigationController alloc]initWithRootViewController:my];
    myNvc.title = @"我";
    myNvc.tabBarItem.image = [UIImage imageNamed:@"my"];
    
    self.viewControllers = @[maiNvc,jingNvc,fuwuNvc,myNvc];

@interface MyViewController ()
{
    //文字数组
    NSArray* arr1,*arr2;
    //图片数组
    NSArray* arrimg1,*arrimg2;
}
@property(nonatomic,strong)UITableView* tableview;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //设置背景颜色
    self.view.backgroundColor = [UIColor whiteColor];
    //导航左按钮
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(way1)];
    //导航右按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(way2)];
    //表格初始化
    self.tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, -35, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.view addSubview:self.tableview];
    
    arr1 = [NSArray arrayWithObjects:@"卡包",@"账单",@"会员中心",@"我的资产", nil];
    arr2 = [NSArray arrayWithObjects:@"我的白条",@"我的金条",@"我的保险",@"我的众筹", nil];
    arrimg1 = [NSArray arrayWithObjects:[UIImage imageNamed:@"Y1"], [UIImage imageNamed:@"Y2"], [UIImage imageNamed:@"Y3"], [UIImage imageNamed:@"ww"], nil];
    arrimg2 = [NSArray arrayWithObjects:[UIImage imageNamed:@"Y1"], [UIImage imageNamed:@"Y2"], [UIImage imageNamed:@"Y3"], [UIImage imageNamed:@"ww"], nil];
}
//设置每一分区单元格数量
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }
    else if (section == 1){
        return 4;
    }
    else if (section == 2){
        return 4;
    }
    return 0;
}
//设置分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
//设置分区每一单元格高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
           return 120;
        }
        else if (indexPath.row == 1){
            return 110;
        }
       
    }
    else
    {
        return 60;
    }
    return 0;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@" "];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@" "];
    }
     if (indexPath.section == 0){
        if (indexPath.row == 0) {
            //设置头像
            UIImageView* img = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 70, 70)];
            img.image = [UIImage imageNamed:@"ww"];
            img.layer.cornerRadius = img.frame.size.width/2.0;
            img.layer.masksToBounds = YES;
            [cell addSubview:img];
            //右侧箭头
            cell.accessoryType = YES;
            //设置登录文字
            UILabel* lab1 = [[UILabel alloc]initWithFrame:CGRectMake(100, 27, 100, 40)];
            lab1.text = @"立即登录";
            lab1.font = [UIFont systemFontOfSize:18];
            [cell addSubview:lab1];
            
            //设置登录下方文字
            UILabel* lab2 = [[UILabel alloc]initWithFrame:CGRectMake(100, 53, 200, 40)];
            lab2.text = @"首次登录,领666元大礼包";
            lab2.textColor = [UIColor orangeColor];
            lab2.font = [UIFont systemFontOfSize:12];
            [cell addSubview:lab2];
        }
        else if (indexPath.row == 1){
 //按钮1----------------------------------------------------------
            UIButton* button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button1.frame = CGRectMake(20, 10, 70, 70);
            button1.clipsToBounds=YES;
            button1.layer.cornerRadius=35;
            button1.backgroundColor = [UIColor grayColor];
            [button1 addTarget:self action:@selector(btn1) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button1];
            
            UILabel* lab1 = [[UILabel alloc]initWithFrame:CGRectMake(35, 80, 100, 40)];
            lab1.text = @"签到";
            lab1.textColor = [UIColor grayColor];
            [cell addSubview:lab1];
//按钮2----------------------------------------------------------
            UIButton* button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button2.frame = CGRectMake(115, 10, 70, 70);
            button2.clipsToBounds=YES;
            button2.layer.cornerRadius=35;
            button2.backgroundColor = [UIColor grayColor];
            [button2 addTarget:self action:@selector(btn2) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button2];
            
            UILabel* lab2 = [[UILabel alloc]initWithFrame:CGRectMake(115, 80, 100, 40)];
            lab2.text = @"早起打卡";
            lab2.textColor = [UIColor grayColor];
            [cell addSubview:lab2];
   
 //按钮3----------------------------------------------------------
            UIButton* button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button3.frame = CGRectMake(210, 10, 70, 70);
            button3.clipsToBounds=YES;
            button3.layer.cornerRadius=35;
            button3.backgroundColor = [UIColor grayColor];
            [button3 addTarget:self action:@selector(btn3) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button3];
            
            UILabel* lab3 = [[UILabel alloc]initWithFrame:CGRectMake(225, 80, 100, 40)];
            lab3.text = @"日历";
            lab3.textColor = [UIColor grayColor];
            [cell addSubview:lab3];
            
 //按钮4----------------------------------------------------------
            UIButton* button4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button4.frame = CGRectMake(310, 10, 70, 70);
            button4.clipsToBounds=YES;
            button4.layer.cornerRadius=35;
            button4.backgroundColor = [UIColor grayColor];
            [button4 addTarget:self action:@selector(btn4) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button4];
            
            UILabel* lab4 = [[UILabel alloc]initWithFrame:CGRectMake(325, 80, 100, 40)];
            lab4.text = @"任务";
            lab4.textColor = [UIColor grayColor];
            [cell addSubview:lab4];
        }
    }
     if (indexPath.section == 1){
         cell.imageView.image = arrimg1[indexPath.row];
         cell.textLabel.text = arr1[indexPath.row];
         
     }
    if (indexPath.section == 2){
        cell.imageView.image = arrimg2[indexPath.row];
        cell.textLabel.text = arr2[indexPath.row];
    }
    return cell;
}
//按钮式
-(void)btn1{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"签到" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [btn11 show];
}
-(void)btn2{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"早起打卡" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [btn11 show];
}
-(void)btn3{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"日历" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [btn11 show];
}
-(void)btn4{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"任务" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [btn11 show];
}
-(void)way1{
    UIAlertView* alter1 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"我" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alter1 show];
}
-(void)way2{
    UIAlertView* alter2 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"我" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alter2 show];
}











你可能感兴趣的:(iOS-图书管理系统)