友盟音乐

导入友盟统计
在这里插入图片描述
手动加入在这里插入图片描述
导航(加入头文件)
#import “AppDelegate.h”
#import “ViewController.h”

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:[ViewController new]];
    return YES;
    }

代码:
#import “ViewController.h”
#import “TWOViewController.h”

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
{
//分段控制器
UISegmentedControl *seg;
//表格
UITableView *tbv;
//主标题数组
NSArray *arr;
//副标题数组
NSArray *fuarr;
}

//左右按钮
@property(nonatomic,strong) UIBarButtonItem *left;
@property(nonatomic,strong) UIBarButtonItem *right;

@end

@implementation ViewController

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

    //左侧按钮,右侧按钮
    _left = [[UIBarButtonItem alloc]initWithTitle:@"<" style:UIBarButtonItemStyleDone target:self action:nil];
    _right = [[UIBarButtonItem alloc]initWithTitle:@"…" style:UIBarButtonItemStyleDone target:self action:nil];

    self.navigationItem.leftBarButtonItem = _left;
    self.navigationItem.rightBarButtonItem = _right;

    //开关控制器
    seg = [[UISegmentedControl alloc]initWithItems:@[@“消息”,@“通知”]];
    seg.frame = CGRectMake(0, 0, 120, 30);
    seg.tintColor = [UIColor redColor];
    // 默认选中
    seg.selectedSegmentIndex = 0;
    [seg addTarget:self action:@selector(click) forControlEvents:UIControlEventValueChanged];

    //将控制器放入到导航
    self.navigationItem.titleView = seg;
    tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    tbv.delegate = self;
    tbv.dataSource = self;

    // 头视图 创建一个VIEW 用来添加按钮 搜索条
    UIView *vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,70)];
    //按钮
    UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 140, 40)];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn setTitle:@“单曲16” forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor whiteColor];

    UIButton * btn1 = [[UIButton alloc]initWithFrame:CGRectMake(140, 0, 150, 40)];
    [btn1 setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn1 setTitle:@“歌手16” forState:UIControlStateNormal];
    btn1.backgroundColor = [UIColor whiteColor];

    UIButton * btn2 = [[UIButton alloc]initWithFrame:CGRectMake(280, 0, 150, 40)];
    [btn2 setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn2 setTitle:@“专辑16” forState:UIControlStateNormal];
    btn2.backgroundColor = [UIColor whiteColor];

    // 搜索条
    UISearchBar *sousuo = [[UISearchBar alloc]initWithFrame:CGRectMake(30, 40, 350, 30)];
    //sousuo.backgroundColor = [UIColor orangeColor];
    sousuo.placeholder = @“请输入搜索的内容。。。”;
    [vi addSubview:btn];
    [vi addSubview:btn1];
    [vi addSubview:btn2];
    [vi addSubview:sousuo];

    // 把VIEW设置成头视图
    tbv.tableHeaderView = vi;

    //底部视图 用来设置歌曲名片
    UIView * uiv = [[UIView alloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width, 80)];
    uiv.backgroundColor = [UIColor whiteColor];
    UIImageView * imag = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, 60, 60)];
    imag.image = [UIImage imageNamed:@“ff”];
    imag.layer.masksToBounds = YES;
    imag.layer.cornerRadius = 30;
    [uiv addSubview: imag];
    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(90, 10, 100, 20)];
    lab.text = @“都选C”;
    lab.textColor = [UIColor blackColor];
    [uiv addSubview:lab];
    UILabel * lab1 = [[UILabel alloc]initWithFrame:CGRectMake(90,40, 150, 20)];
    lab1.text = @“左右滑动可切换上下首”;
    lab1.font = [UIFont systemFontOfSize:13];
    lab1.textColor = [UIColor orangeColor];
    lab1.attributedText = [[NSAttributedString alloc] initWithString:@“左右横滑可切换上下曲” attributes:@{NSForegroundColorAttributeName:[UIColor colorWithPatternImage:[UIImage imageNamed:@“aa”]]}];
    [uiv addSubview:lab1];
    UIImageView * imagvc = [[UIImageView alloc]initWithFrame:CGRectMake(280, 10, 50, 50)];
    imagvc.image = [UIImage imageNamed:@“4”];
    [uiv addSubview:imagvc];

    tbv.tableFooterView = uiv;

    //主标题
    arr = @[@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”];
    //副标题
    fuarr = @[@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“兰花指”];

    [self.view addSubview:tbv];
    }
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return arr.count;
    }
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@“bb”];
    if (!cell) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@“bb”];
    }
    tbv.rowHeight = 60;

    if (indexPath.row==0) {
    UIImageView * ima = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 40, 40)];
    ima.image = [UIImage imageNamed:@“ff”];
    UIImageView * imag = [[UIImageView alloc]initWithFrame:CGRectMake(350, 10, 40, 40)];
    imag.image = [UIImage imageNamed:@“bb”];
    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(60, 20, 100, 20)];
    lab.text =@“全部播放”;
    [cell addSubview:ima];
    [cell addSubview:lab];
    [cell addSubview:imag];
    }else{
    UIImageView * ima = [[UIImageView alloc]initWithFrame:CGRectMake(320, 15, 30, 30)];
    ima.image = [UIImage imageNamed:@“cc”];
    [cell addSubview:ima];
    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(370, 10, 30, 30)];
    lab.text = @"…";
    [cell addSubview:lab];
    cell.textLabel.text = arr[indexPath.row];
    cell.detailTextLabel.text = fuarr[indexPath.row];
    }

    return cell;
    }
    -(void)click{

    if(seg.selectedSegmentIndex == 0){

    }else{
    //跳转到第二个视图
    TWOViewController *two = [[TWOViewController alloc]init];
    [self.navigationController pushViewController:two animated:nil];
    }
    }
    @end

创建分页面(继承于ViewController)
#import “TWOViewController.h”
#import “ViewController.h”

@interface TWOViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UISegmentedControl *seg;
UITableView * tbv;
NSArray * arr;
NSArray * fuarr;

}
@property(nonatomic,strong) UIBarButtonItem *left;
@property(nonatomic,strong) UIBarButtonItem *right;
@end

@implementation TWOViewController

  • (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _left = [[UIBarButtonItem alloc]initWithTitle:@"<" style:UIBarButtonItemStyleDone target:self action:@selector(abcv)];
    _right = [[UIBarButtonItem alloc]initWithTitle:@"…" style:UIBarButtonItemStyleDone target:self action:nil];
    self.navigationItem.leftBarButtonItem = _left;
    self.navigationItem.rightBarButtonItem = _right;
    seg = [[UISegmentedControl alloc]initWithItems:@[@“消息”,@“通知”]];
    seg.frame = CGRectMake(0, 0, 120, 30);
    // 颜色
    seg.tintColor = [UIColor redColor];
    seg.selectedSegmentIndex = 1;
    [seg addTarget:self action:@selector(click) forControlEvents:UIControlEventValueChanged];
    arr = @[@“兰花指”,@“兰”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”,@“兰花指”];
    fuarr = @[@“霍建华/ · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”,@“霍建华/赵丽颖 · 花千骨电视剧原生带 · 《花千骨》”];
    self.navigationItem.titleView = seg;
    tbv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    tbv.delegate = self;
    tbv.dataSource = self;
    //头视图
    UIView *vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,70)];
    UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 140, 40)];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn setTitle:@“单曲16” forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor whiteColor];

    UIButton * btn1 = [[UIButton alloc]initWithFrame:CGRectMake(140, 0, 150, 40)];
    [btn1 setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn1 setTitle:@“歌手16” forState:UIControlStateNormal];
    btn1.backgroundColor = [UIColor whiteColor];

    UIButton * btn2 = [[UIButton alloc]initWithFrame:CGRectMake(280, 0, 150, 40)];
    [btn2 setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [btn2 setTitle:@“专辑16” forState:UIControlStateNormal];
    btn2.backgroundColor = [UIColor whiteColor];
    [vi addSubview:btn];
    [vi addSubview:btn1];
    [vi addSubview:btn2];
    tbv.tableHeaderView = vi;
    //顶部视图
    UIView * uiv = [[UIView alloc]initWithFrame:CGRectMake(0,self.view.frame.size.height-120, self.view.frame.size.width, 80)];
    uiv.backgroundColor = [UIColor whiteColor];
    UIImageView * imag = [[UIImageView alloc]initWithFrame:CGRectMake(20, 10, 60, 60)];
    imag.image = [UIImage imageNamed:@“bb”];
    imag.layer.masksToBounds = YES;
    imag.layer.cornerRadius = 30;
    [uiv addSubview: imag];

    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(90, 10, 100, 20)];
    lab.text = @“都选C”;
    lab.textColor = [UIColor blackColor];
    [uiv addSubview:lab];

    UILabel * lab1 = [[UILabel alloc]initWithFrame:CGRectMake(90,40, 150, 20)];
    lab1.text = @“左右滑动可切换上下首”;
    lab1.font = [UIFont systemFontOfSize:13];
    lab1.textColor = [UIColor orangeColor];
    lab1.attributedText = [[NSAttributedString alloc] initWithString:@“左右横滑可切换上下曲” attributes:@{NSForegroundColorAttributeName:[UIColor colorWithPatternImage:[UIImage imageNamed:@“cc”]]}];
    [uiv addSubview:lab1];
    UIImageView * imagvc = [[UIImageView alloc]initWithFrame:CGRectMake(280, 10, 50, 50)];
    imagvc.image = [UIImage imageNamed:@“cc”];
    [uiv addSubview:imagvc];

    [self.view addSubview:tbv];
    [self.view addSubview:uiv];
    }
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return arr.count;
    }
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@“2”];
    if (!cell) {
    cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@“2”];
    }
    if (indexPath.row==0) {
    cell.textLabel.text =@“推荐你听更多好音乐”;
    }else if (indexPath.row ==6)
    {
    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(140, 10, 150, 30)];
    lab.text =@“发现更多好音乐 >”;
    [cell addSubview:lab];
    }else{
    cell.textLabel.text = arr[indexPath.row];
    cell.detailTextLabel.text = fuarr[indexPath.row];
    }

    return cell;
    }
    -(void)click{

    if(seg.selectedSegmentIndex == 0){
    //跳转到第一个视图
    ViewController *one = [ViewController new];
    [self.navigationController pushViewController:one animated:nil];

    }else{

    }
    }

-(void)abcv{

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    }
    */

@end

统计:
#import “ViewController.h”
#define APPkey @“5bd954bbf1f5566d38000234”
#import <UMCommon/UMCommon.h>
#import <UMCommonLog/UMCommonLogHeaders.h>
#import <UMAnalytics/MobClick.h>

统计代码:
[UMConfigure initWithAppkey:APPkey channel:@“App Store”];
//开发者需要显式的调用此函数,日志系统才能工作
[UMCommonLogManager setUpUMCommonLogManager];
// 关闭Crash收集
[MobClick setCrashReportEnabled:NO];

猜你喜欢

转载自blog.csdn.net/weixin_43656435/article/details/83926580