iOS 滚动视图清楚解释

2019-04-07  本文已影响0人  财奴

vvvvvvvvvvvvvvm

#import "ViewController.h"

#import "TiaoZhuanViewController.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UISearchBar * search;

@property(nonatomic,strong)UITableView * tbv;

@property(nonatomic,strong)UIScrollView * scroll;

@end

@implementation ViewController

//懒加载表格

-(UITableView *)tbv{

    if(!_tbv){

        _tbv=[[UITableView alloc]initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, self.view.frame.size.height-200) style:UITableViewStylePlain];

        _tbv.delegate=self;

        _tbv.dataSource=self;

    }

    return _tbv;

}

//懒加载滚动视图

-(UIScrollView *)scroll{

    if(!_scroll){

        _scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];

        _scroll.contentSize = CGSizeMake(self.view.frame.size.width *3, 0);

        _scroll.bounces=YES;

        _scroll.pagingEnabled =YES;

        _scroll.showsHorizontalScrollIndicator = NO;

        NSArray * arr =@[@"300-1.jpeg",@"6.jpeg",@"300-3.jpeg"];

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

            UIImageView * imgv=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*i, 0, self.view.frame.size.width, 200)];

            imgv.image=[UIImageimageNamed:arr[i]];

            [_scrolladdSubview:imgv];

        }

    }

    return _scroll;

}

//初始化UI控件

-(void)initUI{

    //初始化搜索框

    self.search =[[UISearchBar alloc]initWithFrame:CGRectMake(30, 40, self.view.frame.size.width-60, 30)];

    self.search.placeholder = @"宋MAX |奔驰GLE| 克莱斯勒";

    self.search.barStyle=0;

    self.search.backgroundColor = [UIColor clearColor];

    self.search.backgroundImage = [UIImage new];

    [self.viewaddSubview:self.search];

    UIImageView* oneImgv=[[UIImageViewalloc]initWithFrame:CGRectMake(2,40,25,25)];

    oneImgv.image=[UIImageimageNamed:@"绿巨人.jpg"];

    [self.viewaddSubview:oneImgv];

    UIImageView * TwoImgv=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width-32, 40, 25, 25)];

    TwoImgv.image=[UIImageimageNamed:@"方块+.png"];

    [self.viewaddSubview:TwoImgv];

}

- (void)viewDidLoad {

    [super viewDidLoad];

   //隐藏导航栏

    self.navigationController.navigationBar.hidden = YES;

    //设置背景颜色为白色

    self.view.backgroundColor =[UIColor whiteColor];

    //添加表格

    [self.viewaddSubview:self.tbv];

    //添加滚动视图

    [self.viewaddSubview:self.scroll];

    //执行初始化控件

    [selfinitUI];

}

//实现表格的数据源和代理

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

    return 5;

}

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

    staticNSString* identifier =@"MyCell";

    UITableViewCell* cell =[tableViewdequeueReusableCellWithIdentifier:identifier];

    if(!cell){

        cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

    }

    if(indexPath.row==0){

        UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(10,10,self.view.frame.size.width-100,30)];

        label.text=@"比亚迪春季新品发布会";

        [celladdSubview:label];

        UIImageView * imgv =[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width-130, 5, 100, 40)];

        imgv.image=[UIImageimageNamed:@"1200.png"];

        [celladdSubview:imgv];

    }

    elseif(indexPath.row==1){

        NSArray * arr =@[@"西红柿.png",@"小树苗.png",@"蘑菇.png",@"青椒辣椒.png",@"蔬菜大蒜.png"];

        NSArray * arrTitle=@[@"新车特卖",@"汽车点评",@"七步买车",@"特惠直降",@"0息购车"];

        NSArray * TwoArr =@[@"蔬菜胡萝卜.png",@"白菜花.png",@"红青椒.png",@"黄生菜.png",@"老玉米.png"];

        NSArray * TwoArrTitle =@[@"汽车口碑",@"查违章",@"成交价曝光",@"车型对比",@"二手车产品"];

        for(inti =0; i<5; i++) {

            UIButton* btn =[[UIButtonalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,0,60,60)];

            [btnsetImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];

            [btnaddTarget:self action:@selector(Click:) forControlEvents:UIControlEventTouchUpInside];

            [btnsetTag:100+i];

            [celladdSubview:btn];

        }

        for(inti =0; i<5; i++) {

            UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,60,70,40)];

            label.text= arrTitle[i];

            [celladdSubview:label];

        }

        for(inti =0; i<5; i++) {

            UIButton* Twobtn =[[UIButtonalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,100,60,60)];

            [TwobtnsetImage:[UIImage imageNamed:TwoArr[i]] forState:UIControlStateNormal];

            [celladdSubview:Twobtn];

        }

        for(inti =0; i<5; i++) {

            UILabel* Twolabel =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,160,70,40)];

            Twolabel.text= arrTitle[i];

            [celladdSubview:Twolabel];

        }

    }

    elseif(indexPath.row==2){

        UIScrollView * scr=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)];

        scr.contentSize = CGSizeMake(self.view.frame.size.width *2, 0);

        scr.bounces=NO;

        scr.pagingEnabled=NO;

        scr.showsHorizontalScrollIndicator = NO;

        NSArray * arr =@[@"关注",@"推荐",@"原创",@"车价号",@"小视频",@"世界赛",@"美食",@"模式",@"商家码",@"安生"];

        for(inti=0; i<10; i++) {

            UILabel* label=[[UILabelalloc]initWithFrame:CGRectMake((self.view.frame.size.width*2-60*10)/11*i +60* i ,0,60,50)];

            label.text= arr[i];

            label.textColor=[UIColorredColor];

            [scraddSubview:label];

        }

        [celladdSubview:scr];

    }

    elseif(indexPath.row==3){

        UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(10,0,self.view.frame.size.width-20,50)];

        label.text = @"汽车之家2018年海外品牌进口车质量报告";

        [celladdSubview:label];

    }

    elseif(indexPath.row==4){

        UIImageView * one =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width/3-1, 150)];

        one.image=[UIImageimageNamed:@"4.jpeg"];

        [celladdSubview:one];

        UIImageView * two =[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/3, 0, self.view.frame.size.width/3-1, 150)];

        two.image=[UIImageimageNamed:@"300-5.jpeg"];

        [celladdSubview:two];

        UIImageView * three =[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/3*2, 0, self.view.frame.size.width/3-1, 150)];

        three.image=[UIImageimageNamed:@"300-2.jpeg"];

        [celladdSubview:three];

    }

    returncell;

}

-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{

    if(indexPath.row==0)

    {

        return50;

    }

    elseif(indexPath.row==1){

        return200;

    }

    elseif(indexPath.row==2){

        return50;

    }

    elseif(indexPath.row==3){

        return50;

    }

    elseif(indexPath.row==4){

        return150;

    }

    return 0;

}

//实现点击方法

-(void)Click:(UIButton*)button{

    NSUIntegerbtnTag =[buttontag];

    if(btnTag ==100){

        NSLog(@"wo");

        UINavigationController * nav =[[UINavigationController alloc]initWithRootViewController:[TiaoZhuanViewController new]];

        [self presentViewController:nav animated:NO completion:nil];

    }

}

@end

-090878676543=012887678956789865676776890787

tiaommmmmmmmmmmmmmmmmm

#import "TiaoZhuanViewController.h"

@interface TiaoZhuanViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView * tbv;

@property(nonatomic,strong)UIScrollView * scroll;

@property(nonatomic,strong)UISearchBar * search;

@end

@implementationTiaoZhuanViewController

//懒加载表格

-(UITableView *)tbv{

    if(!_tbv){

        _tbv=[[UITableView alloc]initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, self.view.frame.size.height-200) style:UITableViewStylePlain];

        _tbv.delegate=self;

        _tbv.dataSource=self;

    }

    return _tbv;

}

//懒加载滚动视图

-(UIScrollView *)scroll{

    if(!_scroll){

        _scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200)];

        _scroll.contentSize = CGSizeMake(self.view.frame.size.width *3, 0);

        _scroll.bounces=YES;

        _scroll.pagingEnabled =YES;

        _scroll.showsHorizontalScrollIndicator = NO;

        NSArray * arr =@[@"19.jpg",@"9.jpeg",@"8.jpeg"];

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

            UIImageView * imgv=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width*i, 0, self.view.frame.size.width, 200)];

            imgv.image=[UIImageimageNamed:arr[i]];

            [_scrolladdSubview:imgv];

        }

    }

    return _scroll;

}

//初始化UI控件

-(void)initUI{

    //初始化搜索框

    self.search =[[UISearchBar alloc]initWithFrame:CGRectMake(30, 5, self.view.frame.size.width-60, 30)];

    self.search.placeholder = @"输入品牌、车系、店铺试试";

    self.search.barStyle=0;

    self.search.backgroundColor = [UIColor clearColor];

    self.search.backgroundImage = [UIImage new];

    [self.viewaddSubview:self.search];

    UIImageView * TwoImgv=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width-32, 5, 25, 25)];

    TwoImgv.image=[UIImageimageNamed:@"方块+.png"];

    [self.viewaddSubview:TwoImgv];

}

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor =[UIColor whiteColor];

    self.navigationController.navigationBar.translucent = NO;

    self.navigationItem.title=@"【车商城】汽车之家";

    self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(Fanhui)];

    //添加表格

    [self.viewaddSubview:self.tbv];

    //添加滚动视图

    [self.viewaddSubview:self.scroll];

    [selfinitUI];

}

//实现表格的数据源和代理

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

    return 6;

}

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

    staticNSString* identifier =@"Cell";

    UITableViewCell* cell =[tableViewdequeueReusableCellWithIdentifier:identifier];

    if(!cell){

        cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

    }

    if(indexPath.row==0){

        NSArray * arr =@[@"西红柿.png",@"小树苗.png",@"蘑菇.png",@"青椒辣椒.png",@"蔬菜大蒜.png"];

        NSArray * arrTitle=@[@"厂商直销",@"之家严选",@"新能源",@"新手社区",@"优惠购车"];

        for(inti =0; i<5; i++) {

            UIButton* btn =[[UIButtonalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,0,60,60)];

            [btnsetImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];

            [celladdSubview:btn];

        }

        for(inti =0; i<5; i++) {

            UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,60,70,40)];

            label.text= arrTitle[i];

            [celladdSubview:label];

        }

    }

    elseif(indexPath.row==1){

        UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(10,0,self.view.frame.size.width-20,50)];

        label.text=@"购车快选";

        label.font=[UIFontsystemFontOfSize:25];

        [celladdSubview:label];

        UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(self.view.frame.size.width-40,0,40,50)];

        onelabel.text=@"换一换";

        onelabel.textColor=[UIColorgrayColor];

        onelabel.font=[UIFontsystemFontOfSize:12];

        [celladdSubview:onelabel];

    }

    elseif(indexPath.row==2){

        NSArray * arrTitle=@[@"品牌",@"别克",@"奇瑞",@"马自达",@"名爵"];

        NSArray * oneTitle=@[@"入门代步",@"想买SUV",@"7座大空间",@"家用座驾",@"名爵"];

        for(inti =0; i<5; i++) {

            UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,0,70,25)];

            label.text= arrTitle[i];

            [celladdSubview:label];

        }

        for(inti =0; i<5; i++) {

            UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,30,70,25)];

            onelabel.text= oneTitle[i];

            [celladdSubview:onelabel];

        }

    }

    elseif(indexPath.row==3){

        UIButton* btn =[[UIButtonalloc]initWithFrame:CGRectMake((self.view.frame.size.width-100)/2,5,100,50)];

        [btnsetTitle:@"选车顾问" forState:UIControlStateNormal];

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

        [celladdSubview:btn];

    }

    elseif(indexPath.row==4){

        UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(10,5,self.view.frame.size.width-20,50)];

        label.text=@"汽车严选之家";

        label.font=[UIFontsystemFontOfSize:25];

        [celladdSubview:label];

    }

    elseif(indexPath.row==5){

        NSArray * oneTitle=@[@"热销车",@"带首付",@"低利率",@"低月供",@"名爵"];

        for(inti =0; i<4; i++) {

            UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*4)/5)*i +60*i +(self.view.frame.size.width-60*4)/10,5,70,50)];

            onelabel.text= oneTitle[i];

            onelabel.textColor=[UIColorredColor];

            [celladdSubview:onelabel];

        }

    }

    returncell;

}

//点击返回的方法

-(void)Fanhui{

    [self dismissViewControllerAnimated:NO completion:nil];

}

-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{

    if(indexPath.row==0){

        return100;

    }

    else{

        return  60;

    }

}

@end

87897878326763274632784623784623784678234

appppppppppppph

#import

#import

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property(readonly,strong)NSPersistentContainer*persistentContainer;

- (void)saveContext;

@end

7867821678362781637812687367123

apppppppppm

#import "AppDelegate.h"

#import "ViewController.h"

#import "LunTanViewController.h"

#import "XinCheViewController.h"

#import "ErShouCheViewController.h"

#import "WoViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

    //包装首页的底部控制器

    UINavigationController* ShouYeNav =[[UINavigationController alloc]initWithRootViewController:[ViewController new]];

    ShouYeNav.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"喜欢灰"] selectedImage:[UIImage imageNamed:@"喜欢蓝"]];

    //包装论坛的底部控制器

    UINavigationController * LunTanNav =[[UINavigationController alloc]initWithRootViewController:[LunTanViewController new]];

    LunTanNav.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"论坛" image:[UIImage imageNamed:@"收藏灰"] selectedImage:[UIImage imageNamed:@"收藏蓝"]];

    //包装新车的底部控制器

    UINavigationController* XinCheNav =[[UINavigationController alloc]initWithRootViewController:[XinCheViewController new]];

    XinCheNav.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"新车" image:[UIImage imageNamed:@"消息灰"] selectedImage:[UIImage imageNamed:@"消息蓝"]];

    //包装二手车的底部控制器

    UINavigationController* ErShouCheNav =[[UINavigationController alloc]initWithRootViewController:[ErShouCheViewController new]];

    ErShouCheNav.tabBarItem=[[UITabBarItemalloc]initWithTitle:@"二手车"image:[UIImageimageNamed:@"密码 (2).png"]selectedImage:[UIImageimageNamed:@"密码 (1).png"]];

    //包装我的底部控制器

    UINavigationController* WoNav =[[UINavigationController alloc]initWithRootViewController:[WoViewController new]];

    WoNav.tabBarItem =[[UITabBarItem alloc]initWithTitle:@"我" image:[UIImage imageNamed:@"我的灰"] selectedImage:[UIImage imageNamed:@"我的蓝"]];

lunmmmmmmmmmmmmh

#import "LunTanViewController.h"

@interface LunTanViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UISearchBar * search;

@property(nonatomic,strong)UITableView * tbv;

@end

@implementationLunTanViewController

//懒加载表格

-(UITableView *)tbv{

    if(!_tbv){

        _tbv=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];

        _tbv.delegate=self;

        _tbv.dataSource=self;

    }

    return _tbv;

}

//初始化UI控件

-(void)initUI{

    //初始化搜索框

    self.search =[[UISearchBar alloc]initWithFrame:CGRectMake(30, 40, self.view.frame.size.width-60, 30)];

    self.search.placeholder = @"车友圈  Young  视频社区";

    self.search.barStyle=0;

    self.search.backgroundColor = [UIColor clearColor];

    self.search.backgroundImage = [UIImage new];

    self.navigationItem.titleView = self.search;

    UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(2,0,25,25)];

    label.text=@"论坛";

    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:label];

    UIImageView * TwoImgv=[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width-32, 40, 25, 25)];

    TwoImgv.image=[UIImageimageNamed:@"方块+.png"];

    self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc]initWithCustomView:TwoImgv];

}

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor =[UIColor whiteColor];

    self.navigationController.navigationBar.translucent =NO;

    [selfinitUI];

    [self.viewaddSubview:self.tbv];

}

//实现表格的代理和数据源

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

    return 6;

}

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

    staticNSString* identifier =@"QCell";

    UITableViewCell* cell =[tableViewdequeueReusableCellWithIdentifier:identifier];

    if(!cell){

        cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

    }

    if(indexPath.row==0){

        NSArray * arr =@[@"西红柿.png",@"小树苗.png",@"蘑菇.png",@"青椒辣椒.png",@"蔬菜大蒜.png"];

        NSArray * arrTitle=@[@"全部论坛",@"宋MAX",@"居家论坛",@"宝马3撕裂",@"躺新能"];

        for(inti =0; i<5; i++) {

            UIButton* btn =[[UIButtonalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,0,50,60)];

            [btnsetImage:[UIImage imageNamed:arr[i]] forState:UIControlStateNormal];

            [btnsetTag:100+i];

            [celladdSubview:btn];

        }

        for(inti =0; i<5; i++) {

            UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-60*5)/6)*i +60*i +(self.view.frame.size.width-60*5)/12,50,70,30)];

            label.text= arrTitle[i];

            [celladdSubview:label];

        }

    }

    elseif(indexPath.row==1){

        UIImageView *imgv =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 80)];

        imgv.image=[UIImageimageNamed:@"06.jpg"];

        [celladdSubview:imgv];

    }

    elseif(indexPath.row==2){

        UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(10,0,self.view.frame.size.width-20,50)];

        label.text=@"车主秀";

        label.font=[UIFontsystemFontOfSize:25];

        [celladdSubview:label];

        UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(self.view.frame.size.width-40,0,40,50)];

        onelabel.text=@"更多->";

        onelabel.textColor=[UIColorgrayColor];

        onelabel.font=[UIFontsystemFontOfSize:12];

        [celladdSubview:onelabel];

    }

    elseif(indexPath.row==3){

        UIImageView * one =[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width/3-1, 150)];

        one.image=[UIImageimageNamed:@"1.jpeg"];

        [celladdSubview:one];

        UIImageView * two =[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/3, 0, self.view.frame.size.width/3-1, 150)];

        two.image=[UIImageimageNamed:@"300.jpeg"];

        [celladdSubview:two];

        UIImageView * three =[[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/3*2, 0, self.view.frame.size.width/3-1, 150)];

        three.image=[UIImageimageNamed:@"300-4.jpeg"];

        [celladdSubview:three];

    }

    elseif(indexPath.row==4){

        UILabel* label =[[UILabelalloc]initWithFrame:CGRectMake(10,0,self.view.frame.size.width-20,50)];

        label.text=@"热门主题";

        label.font=[UIFontsystemFontOfSize:25];

        [celladdSubview:label];

        UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(self.view.frame.size.width-40,0,40,50)];

        onelabel.text=@"更多->";

        onelabel.textColor=[UIColorgrayColor];

        onelabel.font=[UIFontsystemFontOfSize:12];

        [celladdSubview:onelabel];

    }

    elseif(indexPath.row==5){

        NSArray * oneTitle=@[@"#媳妇当车模",@"#没人生活秀",@"#论坛热帖"];

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

            UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-100*3)/4)*i +100*i +(self.view.frame.size.width-100*3)/8,5,100,30)];

            onelabel.text= oneTitle[i];

            onelabel.backgroundColor=[UIColorredColor];

            onelabel.textColor=[UIColorwhiteColor];

            [celladdSubview:onelabel];

        }

        NSArray * Title=@[@"#媳妇当车模",@"#没人生活秀",@"#论坛热帖"];

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

            UILabel* onelabel =[[UILabelalloc]initWithFrame:CGRectMake(((self.view.frame.size.width-100*3)/4)*i +100*i +(self.view.frame.size.width-100*3)/8,110,100,30)];

            onelabel.text= Title[i];

            onelabel.backgroundColor=[UIColororangeColor];

            onelabel.textColor=[UIColorwhiteColor];

            [celladdSubview:onelabel];

        }

    }

    returncell;

}

-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{

    if(indexPath.row==0)

    {

        return90;

    }

    elseif(indexPath.row==1){

        return80;

    }

    elseif(indexPath.row==2){

        return50;

    }

    elseif(indexPath.row==3){

        return150;

    }

    elseif(indexPath.row==4){

        return50;

    }

    elseif(indexPath.row==5){

        return150;

    }

    return 0;

}

@end

上一篇下一篇

猜你喜欢

热点阅读