qq音乐首页

#import "OneViewController.h"
#import "MusicPlayerViewController.h"

@interface OneViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *table;
    UISearchBar *search;
    UISearchDisplayController *dis;
    NSArray *titleArr;
    NSArray *imgArr;
    
}
@end

@implementation OneViewController


-(void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"我的音乐";
    UIBarButtonItem *rightItem =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"13"] style:UIBarButtonItemStylePlain target:self action:@selector(click)];
    self.navigationItem.rightBarButtonItem =rightItem;
    self.navigationController.navigationBar.tintColor =[UIColor greenColor];
    
    table =[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    table.dataSource=self;
    table.delegate=self;
    [self.view addSubview:table];
    
    search =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
    search.placeholder =@"搜索";
    dis =[[UISearchDisplayController alloc]initWithSearchBar:search contentsController:self];
    dis.searchResultsDataSource=self;
    dis.searchResultsDelegate=self;
    table.tableHeaderView=search;
    
    titleArr = @[@"全部歌曲",@"下载歌曲",@"最近播放"];

}
-(void)click
{
    MusicPlayerViewController *mp =[[MusicPlayerViewController alloc]init];
    [self.navigationController pushViewController:mp animated:YES];
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0) {
        return 1;
    }else if (section==1){
        return 3;
    }else
    {
        return 2;
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;
    if(indexPath.section == 0){
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
    }else{
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    }
    if (indexPath.section == 0) {
        cell.imageView.image = [UIImage imageNamed:@"dl"];
        cell.textLabel.text = @"未登录";
        cell.textLabel.font = [UIFont systemFontOfSize:20];
        cell.detailTextLabel.text = @"登录后和朋友们分享";
        cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
        cell.detailTextLabel.textColor = [UIColor lightGrayColor];
        
        UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
        b.frame = CGRectMake(300, 30, 60, 30);
        [b setTitle:@"登录" forState:UIControlStateNormal];
        [b setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
        [b addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
        b.layer.borderWidth = 1;
        b.layer.borderColor = [UIColor greenColor].CGColor;
        b.layer.cornerRadius = 8;
        [cell addSubview:b];
    }else if(indexPath.section == 1){
        cell.imageView.image = [UIImage imageNamed:imgArr[indexPath.row]];
        cell.textLabel.text = titleArr[indexPath.row];
        cell.detailTextLabel.text = @"100首";
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }else{
        if (indexPath.row == 0) {
            cell.textLabel.text = @"我的歌单";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }else{
            cell = [[UITableViewCell alloc]init];
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 40, 300, 40)];
            label.text = @"                ,点击红心收藏喜欢的歌曲,\n同时同步到你的所有设备";
            label.textAlignment = NSTextAlignmentCenter;
            label.font = [UIFont systemFontOfSize:15];
            //lable支持行数 如果-1 自动匹配行。
            label.numberOfLines = -1;
            [cell addSubview:label];
            
            UIButton *b = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            b.frame = CGRectMake(10, -5, 80, 30);
            [b setTitle:@"登录账户" forState:UIControlStateNormal];
            [b setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
            [b addTarget:self action:@selector(clickLoad) forControlEvents:UIControlEventTouchUpInside];
            b.layer.cornerRadius = 4;
            [label addSubview:b];
        }
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 100;
    }else if(indexPath.section == 1){
        return 50;
    }else{
        if (indexPath.row == 0) {
            return 50;
        }else{
            return 120;
        }
    }
}
-(void)clickBtn{
}
-(void)clickLoad{
}

转载于:https://my.oschina.net/suyongchen/blog/672473

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值