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(@"启动成功");


屏幕快照 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;
}


屏幕快照 2017-11-23 下午1.11.28.png
屏幕快照 2017-11-23 下午1.11.37.png
屏幕快照 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 ()<UITableViewDelegate,UITableViewDataSource>
{
    //文字数组
    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];
}











最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,542评论 6 504
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,822评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,912评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,449评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,500评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,370评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,193评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,074评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,505评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,722评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,841评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,569评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,168评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,783评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,918评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,962评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,781评论 2 354

推荐阅读更多精彩内容