网格

#import "oneViewController.h"

#import "twoViewController.h"

@interface oneViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>{

    UICollectionView *clv;

}

@end

@implementationoneViewController

- (void)viewDidLoad {

    [super viewDidLoad];


    self.view.backgroundColor=[UIColor whiteColor];


    [selfSetNav];


    [selfSetUser];


    [selfSetClv];

}

- (void)SetNav{

    self.navigationItem.title=@"月考";

    self.navigationController.navigationBar.barTintColor=[UIColor lightGrayColor];

}

- (void)SetUser{

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

    [UserBtnsetTitle:@"用户名字" forState:UIControlStateNormal];

    [UserBtnsetFont:[UIFont systemFontOfSize:20]];

    [UserBtnsetTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    [UserBtnaddTarget:self action:@selector(TZhuanClick) forControlEvents:UIControlEventTouchUpInside];

    [self.viewaddSubview:UserBtn];

    [self.viewaddSubview:UserBtn];



    UIImageView *TouImg=[[UIImageView alloc]initWithFrame:CGRectMake(300, 80, 60, 60)];

    TouImg.image=[UIImageimageNamed:@"QQicon"];

    TouImg.layer.cornerRadius=25;

    TouImg.layer.masksToBounds=YES;

    [self.viewaddSubview:TouImg];

}

- (void)SetClv{

    UILabel*ServiceLab=[[UILabelalloc]initWithFrame:CGRectMake(30,200,100,30)];

    ServiceLab.text=@"服务";

    [self.viewaddSubview:ServiceLab];



    UICollectionViewFlowLayout *Flow=[[UICollectionViewFlowLayout alloc]init];

    clv=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 250, self.view.frame.size.width, 320) collectionViewLayout:Flow];

    Flow.itemSize=CGSizeMake(100,100);


    clv.delegate=self;

    clv.dataSource=self;


    [clv registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];

    clv.backgroundColor=[UIColor whiteColor];

    [self.view addSubview:clv];

}

- (NSInteger)collectionView:(UICollectionView*)collectionView numberOfItemsInSection:(NSInteger)section{

    return 8;

}

- (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath{

    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];

    NSArray *ArrImg=@[@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12"];

    NSArray *ArrLab=@[@"红包年卡",@"我的行程",@"我的消息",@"我的客服",@"保修助手",@"ofo助手",@"邀请好友",@"天使的蛋生"];

    UIImageView *ClvImg=[[UIImageView alloc]initWithFrame:CGRectMake(10, 0, 70, 70)];

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

    ClvLab.text=ArrLab[indexPath.row];

    ClvImg.image=[UIImageimageNamed:ArrImg[indexPath.row]];


    [celladdSubview:ClvImg];

    [celladdSubview:ClvLab];

    returncell;

}

- (void)TZhuanClick{

    twoViewController *two=[[twoViewController alloc]init];

    [self.navigationController pushViewController:two animated:YES];

}

@end

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • //引导 #import "ViewController.h" #import "MainViewControll...
    朕i阅读 3,414评论 0 0
  • 网格的适配横屏竖屏 注意适配加入iOS第三方 Masonry 图片定义从零开始 //AppDelegate.m #...
    leaderleader阅读 1,950评论 0 2
  • //引导 #import "ViewController.h" #import "MainViewControll...
    朕i阅读 1,801评论 0 0
  • 最近刚好在写《第五项修炼》的文摘,就遇到了这本书的中国译者张成林老师,意外之喜。他选择用一句话推荐这本书:东西方组...
    growingtree阅读 1,490评论 0 0
  • 心似柳絮乱纷纷 卧听蛙鸣已三更 如痴如梦惊觉身渐冷 寒意落地悄无声 岁月何时曾留痕 匆匆流尽不可闻 古今多少往事已...
    竹影斋主人阅读 1,738评论 0 3

友情链接更多精彩内容