美文网首页
基本练习二

基本练习二

作者: 26aa4a305186 | 来源:发表于2018-11-11 19:05 被阅读0次

#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

@implementationtwoViewController

- (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:@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)];

    [btnsetTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    [btnsetTitle:@"单曲16" forState:UIControlStateNormal];

    btn.backgroundColor = [UIColor whiteColor];

    UIButton* btn1 = [[UIButtonalloc]initWithFrame:CGRectMake(140,0,150,40)];

    [btn1setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    [btn1setTitle:@"歌手16" forState:UIControlStateNormal];

    btn1.backgroundColor = [UIColor whiteColor];

    UIButton* btn2 = [[UIButtonalloc]initWithFrame:CGRectMake(280,0,150,40)];

    [btn2setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

    [btn2setTitle:@"专辑16" forState:UIControlStateNormal];

    btn2.backgroundColor = [UIColor whiteColor];

    [viaddSubview:btn];

    [viaddSubview:btn1];

    [viaddSubview: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 = [[UIImageViewalloc]initWithFrame:CGRectMake(20,10,60,60)];

    imag.image= [UIImageimageNamed:@"1"];

    imag.layer.masksToBounds = YES;

    imag.layer.cornerRadius = 30;

    [uivaddSubview: imag];

    UILabel * lab = [[UILabel alloc]initWithFrame:CGRectMake(90, 10, 100, 20)];

    lab.text=@"都选C";

    lab.textColor = [UIColor blackColor];

    [uivaddSubview:lab];

    UILabel * lab1 = [[UILabel alloc]initWithFrame:CGRectMake(90,40, 150, 20)];

    lab1.text = @"左右滑动可切换上下首";

    lab1.font= [UIFontsystemFontOfSize:13];

    lab1.textColor = [UIColor orangeColor];

    lab1.attributedText= [[NSAttributedStringalloc]initWithString:@"左右横滑可切换上下曲"attributes:@{NSForegroundColorAttributeName:[UIColorcolorWithPatternImage:[UIImage imageNamed:@"下载"]]}];

    [uivaddSubview:lab1];

    UIImageView* imagvc = [[UIImageViewalloc]initWithFrame:CGRectMake(280,10,50,50)];

    imagvc.image = [UIImage imageNamed:@"屏幕快照 2018-11-08 下午1.41.54"];

    [uivaddSubview:imagvc];

    [self.view addSubview:tbv];

    [self.viewaddSubview:uiv];

}

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

    returnarr.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=@"推荐你听更多好音乐";

    }elseif(indexPath.row==6)

    {

        UILabel* lab = [[UILabelalloc]initWithFrame:CGRectMake(140,10,150,30)];

        lab.text=@"发现更多好音乐 >";

        [celladdSubview:lab];

    }else{

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

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

    }

    returncell;

}

-(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.

}

*/

相关文章

  • 基本练习二

    #import "twoViewController.h" #import "ViewController.h" ...

  • 硬笔楷书5000常用字(二)

    硬笔楷书5000常用字(二),基本笔画练习

  • 基本练习

  • 基本练习

    首先创建两个属性 //左右按钮 @property(nonatomic,strong) UIBarButtonIt...

  • 单例 - IOS

    一、基本概念 二、创建单例的基本步骤 三、练习: 四、代码 main.m#import

  • 今日简书

    还是ug基本练习,练习

  • 声音修行第三天

    今天是基本功的练习,si音和哈音的练习,想想第二期的自己,觉得基本功练习可以留着以后慢慢儿练不打紧,于是对这两个发...

  • 毛笔字练习第二天

    练习毛笔字 第二天 练习的第二天,感觉基础比较薄弱,笔画写不到位,尤其是带勾的地方很吃力,需要对基本笔画加强练习。...

  • #30天专注成长计划# 声音博客 day3

    声音课程倒数第二天,依然是打开练习。新闻与报纸摘要练习+调值专项练习。 感触:基本功很重要,还是要练习提打挺松,腹...

  • 2017-8-4

    刘诗昆钢琴艺术中心讲考级 ——八级精彩呈现 《新编钢琴考级教程》八级内容: 一、基本练习 二、练习...

网友评论

      本文标题:基本练习二

      本文链接:https://www.haomeiwen.com/subject/yqhffqtx.html