IOS项目BO

#import "ViewController.h"#import "OneViewController.h"#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height@interface ViewController ()@property(nonatomic,strong)UIScrollView *scroll;

@end

@implementation ViewController

-(void)scrollTop{

    //创建滚动试图

    _scroll = [[UIScrollView alloc] initWithFrame:self.view.frame];

    //设置代理

    _scroll.delegate = self;

    //设置滚动范围

    _scroll.contentSize = CGSizeMake(SCREEN_WIDTH * 3, SCREEN_HEIGHT);

    //设置分页滚动

    _scroll.pagingEnabled = YES;

    //添加到视图上

    [self.view addSubview:_scroll];

    //利用循环创建imageview

    for (int i = 0; i< 3; i++) {

        UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

        imageV.image = [UIImage imageNamed:@"4 2"];

        imageV.userInteractionEnabled = YES;

        //添加到滚动视图上

        [_scroll addSubview:imageV];

        //判断创建button

        if (i == 2) {

            UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

            btn.frame = CGRectMake((SCREEN_WIDTH - SCREEN_WIDTH / 6)/2, SCREEN_HEIGHT - 40*2, SCREEN_WIDTH / 6, 40);

            [btn setTitle:@"进入播放" forState:UIControlStateNormal];

            [btn addTarget:self action:@selector(btn1) forControlEvents:UIControlEventTouchUpInside];

            //将button添加到图片上

            [imageV addSubview:btn];

        }

    }

}

- (void)viewDidLoad {

    [super viewDidLoad];

    //调用scrollview

    [self scrollTop];

}

//button点击事件

-(void)btn1{

    NSLog(@"进入首页");

    OneViewController *one = [[OneViewController alloc] init];

    [self presentViewController:one animated:YES completion:^{

    }];

}

@end

#import "OneViewController.h"#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height@interface OneViewController (){

    UIButton *_lastButton;

    UIView *view;

    UIImageView *imagea;

    UITableView *table;

    NSMutableArray *arrtab;

}

@property(nonatomic,strong)UIButton *butten,*buttenCenter,*button;

@property(nonatomic,strong)UIScrollView *scrollV,*scrollCenter,*scrool;;

@end

@implementation OneViewController

-(void)buttenTopA{

    NSArray *arr = @[@"我的",@"乐库",@"唱歌"];

    for (int i = 0; i< 3; i++) {

        _butten = [UIButton buttonWithType:UIButtonTypeCustom];

        _butten.frame = CGRectMake(SCREEN_WIDTH / 4* i+SCREEN_WIDTH / 6, 20, SCREEN_WIDTH / 6, 40);

        [_butten setTitle:arr[i] forState:UIControlStateNormal];

        [_butten setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        [_butten setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];

        _butten.selected = YES;

        [_butten addTarget:self action:@selector(butten:) forControlEvents:UIControlEventTouchUpInside];

        _butten.tag = 1000+i;

        [self.view addSubview:_butten];

    }

    UIButton *buttem = [UIButton buttonWithType:UIButtonTypeRoundedRect];

    buttem.frame = CGRectMake(10, 20, 40, 40);

    [buttem setTitle:@"🔍" forState:UIControlStateNormal];

    [self.view addSubview:buttem];

}

-(void)scrollView{

    //创建滚动试图

    _scrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT)];

    //设置代理

    _scrollV.delegate = self;

    //设置滚动范围

    _scrollV.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);

    //设置分页滚动

    _scrollV.pagingEnabled = YES;

    //添加到视图上

    [self.view addSubview:_scrollV];

    for (int i = 0; i< 3; i++) {

        UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

        if (i == 0) {

            view1.backgroundColor = [UIColor greenColor];

        }else if (i == 1){

            view1.backgroundColor = [UIColor clearColor];

        }else{

            view1.backgroundColor = [UIColor cyanColor];

        }

        [_scrollV addSubview:view1];

    }

}

-(void)scrollCenterA{

    //创建滚动试图

    _scrollCenter = [[UIScrollView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, 40)];

    //设置代理

    _scrollCenter.delegate = self;

    _scrollCenter.backgroundColor = [UIColor blueColor];

    //设置滚动范围

    _scrollCenter.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);

    //设置分页滚动

    //_scrollCenter.pagingEnabled = YES;

    //添加到视图上

    [_scrollV addSubview:_scrollCenter];

    NSArray *array = @[@"排行",@"歌手",@"电台",@"人群",@"推荐",@"心情",@"主题",@"儿歌"];

    for (int i = 0; i< 8; i++) {

        _buttenCenter = [UIButton buttonWithType:UIButtonTypeCustom];

        _buttenCenter.frame = CGRectMake(SCREEN_WIDTH / 6* i, 0, SCREEN_WIDTH / 6, 40);

        [_buttenCenter setTitle:array[i] forState:UIControlStateNormal];

        [_buttenCenter setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        [_buttenCenter setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];

        _buttenCenter.selected = YES;

        [_buttenCenter addTarget:self action:@selector(clickButten:) forControlEvents:UIControlEventTouchUpInside];

        _buttenCenter.tag = 1000+i;

        [_scrollCenter addSubview:_buttenCenter];

    }

}

-(void)buttonLeft{

    NSArray *array1 = @[@"推荐",@"心情",@"主题",@"人群",@"场景",@"曲风",@"雨中",@"乐器",@"歌手"];

    for (int i = 0; i< 8; i++) {

        _button = [UIButton buttonWithType:UIButtonTypeCustom];

        _button.frame = CGRectMake(0, SCREEN_HEIGHT / 10*i, SCREEN_WIDTH / 6, 40);

        [_button setTitle:array1[i] forState:UIControlStateNormal];

        [_button setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];

        [_button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

        _button.selected = YES;

        [_button addTarget:self action:@selector(btn1a:) forControlEvents:UIControlEventTouchUpInside];

        _button.tag = 1000+i;

        [imagea addSubview:_button];

    }

}

-(void)scroolView{

    //创建滚动试图

    _scrool = [[UIScrollView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH, 40, SCREEN_WIDTH, SCREEN_HEIGHT)];

    //设置代理

    _scrool.delegate = self;

    //设置滚动范围

    _scrool.contentSize = CGSizeMake(SCREEN_WIDTH * 8, 0);

    //设置分页滚动

    _scrool.pagingEnabled = YES;

    //添加到视图上

    [_scrollV addSubview:_scrool];

    for (int i = 0; i< 8; i++) {

        view = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * i, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];

        if (i == 0) {

            view.backgroundColor = [UIColor greenColor];

        }else if (i == 1){

            view.backgroundColor = [UIColor clearColor];

        }else if (i == 2){

            view.backgroundColor = [UIColor yellowColor];

            imagea = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 104 - 65)];

            imagea.image = [UIImage imageNamed:@"u=1155422752,2817714038&fm=27&gp=0"];

            imagea.userInteractionEnabled = YES;

            [view addSubview:imagea];

            UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 170, SCREEN_WIDTH, 65)];

            toolbar.barTintColor = [UIColor grayColor];

            [imagea addSubview:toolbar];

            UIImageView *imageaa = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 65)];

            imageaa.image = [UIImage imageNamed:@"4EA8715B392B9CFCF1B7000138338BC7"];

            [toolbar addSubview:imageaa];

            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(70, 0, 100, 35)];

            label.text = @"白松";

            [toolbar addSubview:label];

            UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(70, 35, 100, 35)];

            label1.text = @"松";

            label1.font = [UIFont systemFontOfSize:14];

            [toolbar addSubview:label1];

            UIImageView *imagebb = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 200, 20, 40, 40)];

            imagebb.image = [UIImage imageNamed:@"u=2132620800,3533375095&fm=200&gp=0"];

            [toolbar addSubview:imagebb];

            UIImageView *imagebba = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 120, 20, 40, 40)];

            imagebba.image = [UIImage imageNamed:@"u=2132620800,3533375095&fm=200&gp=0"];

            [toolbar addSubview:imagebba];

            UIImageView *imagebbc = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 60, 20, 40, 40)];

            imagebbc.image = [UIImage imageNamed:@"u=2132620800,3533375095&fm=200&gp=0"];

            [toolbar addSubview:imagebbc];

        }else if (i == 3){

            view.backgroundColor = [UIColor clearColor];

        }else if (i == 4){

            view.backgroundColor = [UIColor orangeColor];

        }else if (i == 5){

            view.backgroundColor = [UIColor cyanColor];

        }else if (i == 6){

            view.backgroundColor = [UIColor greenColor];

        }else if (i == 7){

            view.backgroundColor = [UIColor grayColor];

        }else{

            view.backgroundColor = [UIColor redColor];

        }

        [_scrool addSubview:view];

    }

}

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor cyanColor];

    [self buttenTopA];

    [self scrollView];

    [self scrollCenterA];

    [self scroolView];

    [self buttonLeft];

}

-(void)butten:(UIButton *)sender{

    sender.selected = NO;

    _lastButton.selected = YES;

    _lastButton = sender;

    _scrollV.contentOffset = CGPointMake((sender.tag - 1000)*SCREEN_WIDTH, 0);

}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

    int offSet = _scrollV.contentOffset.x;

    int index = offSet / SCREEN_WIDTH;

    NSLog(@"%d",index);

    int btnTag = 1000+index;

  // UIButton *btn = [self.view viewWithTag:btnTag];

}

-(void)clickButten:(UIButton *)sendera{

    sendera.selected = NO;

    _lastButton.selected = YES;

    _lastButton = sendera;

    _scrool.contentOffset = CGPointMake((sendera.tag - 1000)*SCREEN_WIDTH, 0);

}

-(void)btn1a:(UIButton *)senderbtn{

    senderbtn.selected = NO;

    _lastButton.selected = YES;

    _lastButton = senderbtn;

    table = [[UITableView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 6, 0, SCREEN_WIDTH - SCREEN_WIDTH / 6, SCREEN_HEIGHT - 180)];

    table.delegate = self;

    table.dataSource = self;

    table.rowHeight = 80;

    table.backgroundColor = [UIColor clearColor];

    [imagea addSubview:table];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    return 7;

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *str = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:str];

    if (!cell) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];

    }

    NSArray *arr = @[@"index",@"index",@"index",@"index",@"index",@"index",@"index"];

    NSArray *arr2 = @[@"一人一首成名曲",@"经典怀旧",@"网络热歌",@"秋天",@"90后电台",@"雨天",@"理发店"];

    NSArray *arr3 = @[@"3200.23万人在听",@"320.23万人在听",@"5173.23万人在听",@"886.01万人在听",@"37.9821万人在听",@"3721.00万人在听",@"5432.09万人在听"];

    cell.imageView.image = [UIImage imageNamed:arr[indexPath.row]];

    cell.textLabel.text = arr2[indexPath.row];

    cell.detailTextLabel.text = arr3[indexPath.row];

    cell.backgroundColor = [UIColor clearColor];

    return cell;

}

@end

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

推荐阅读更多精彩内容