美文网首页
ios我的页面

ios我的页面

作者: syh1234 | 来源:发表于2018-06-11 15:48 被阅读0次

    AppDelegate.m


    #import "AppDelegate.h"

    #import "ViewController.h"

    #import "FirstViewController.h"

    #import "SecViewController.h"

    #import "ThirdViewController.h"

    #import "FourthViewController.h"

    @interface AppDelegate ()

    @end

    @implementation AppDelegate

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

    //首页

        ViewController *vc=[[ViewController alloc]init];

        UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:vc];

        nav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@"首页"] tag:0];

    //分类

        FirstViewController *firstVc=[[FirstViewController alloc]init];

        UINavigationController *firstNav=[[UINavigationController alloc]initWithRootViewController:firstVc];

        firstNav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"分类" image:[UIImage imageNamed:@"购物车"] tag:0];

        //闲置卖

        SecViewController *secvc=[[SecViewController alloc]init];

        UINavigationController *secnav=[[UINavigationController alloc]initWithRootViewController:secvc];

        secnav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"闲置卖" image:[UIImage imageNamed:@"微淘"] tag:0];

        //消息

        ThirdViewController *thivc=[[ThirdViewController alloc]init];

        UINavigationController *thinav=[[UINavigationController alloc]initWithRootViewController:thivc];

        thinav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"消息" image:[UIImage imageNamed:@"消息"] tag:0];

        //我的

        FourthViewController *fourvc=[[FourthViewController alloc]init];

        UINavigationController *fournav=[[UINavigationController alloc]initWithRootViewController:fourvc];

        fournav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"我的"] tag:0];

        UITabBarController *tab=[[UITabBarController alloc]init];

        tab.viewControllers=@[nav,firstNav,secnav,thinav,fournav];

        tab.selectedIndex=4;

        self.window.rootViewController=tab;

        return YES;

    }


    FirstViewController


    SecViewController


    ThirdViewController


    FourthViewController


    #import "FourthViewController.h"@interface FourthViewController (){

        UITableView *table;

        NSArray *arr;

    }

    @end

    @implementation FourthViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        self.view.backgroundColor=[UIColor whiteColor];

        table=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];

        table.delegate=self;

        table.dataSource=self;

        [self.view addSubview:table];

        self.navigationController.navigationBarHidden=YES;

    }

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

        return 3;

    }

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

        if (section==0) {

            return 2;

        }else if (section==1){

            return 1;

        }else{

            return 1;

        }

        return 0;

    }

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

        UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@""];

        if (!cell) {

            cell=[tableView dequeueReusableCellWithIdentifier:@""];

        }

        if (indexPath.section==0) {

            if (indexPath.row==0) {

                UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, -64, self.view.frame.size.width, 300)];

                view.backgroundColor=[UIColor redColor];

                [cell addSubview:view];

                UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(170, 110, 80, 80)];

                img.image=[UIImage imageNamed:@"屏幕快照 2017-10-20 18.56.46"];

                img.layer.masksToBounds = YES;

                // 设置圆角大小

                img.layer.cornerRadius = 40;

                [view addSubview:img];

                UILabel *la=[[UILabel alloc]initWithFrame:CGRectMake(160, 200, 100, 40)];

                la.text=@"King-WU";

                la.font=[UIFont systemFontOfSize:22];

                la.textColor=[UIColor whiteColor];

                [view addSubview:la];

                UILabel *la1=[[UILabel alloc]initWithFrame:CGRectMake(35, 250, 400, 40)];

                la1.text=@"您加入转转已经599天了,成功赚取了1650元";

                la1.textColor=[UIColor whiteColor];

                [view addSubview:la1];

            }

        }

        return cell;

    }

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

        if (indexPath.section==0) {

            if (indexPath.row==0) {

                return 300;

            }else if (indexPath.row==1){

                return 150;

            }

        }else if (indexPath.section==1){

            return 200;

        }else if (indexPath.section==2){

            return 500;

        }

        return 0;

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    /*

    #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


    相关文章

      网友评论

          本文标题:ios我的页面

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