iOS UITabbarController 屌屌的

新建一个项目,

继承

UITabBarController


如.h文件

#import <UIKit/UIKit.h>


@interface ZHBaseViewController : UITabBarController


@end


.m文件

-(void)ViewDidLoad{


//调用

  [self createView];

  [self createTabbar];



}

-(void)createView{


 ZHVideoViewController * video = [[ZHVideoViewController alloc]init];

    UINavigationController * videoVc = [[UINavigationController alloc]initWithRootViewController:video];

   

    

    

    

    ZHAudioViewController * audio = [[ZHAudioViewController alloc]init];

    UINavigationController * audioVc = [[UINavigationController alloc]initWithRootViewController:audio];

    

    ZHPictureViewController * picture = [[ZHPictureViewController alloc]init];

    UINavigationController * pictureVc = [[UINavigationController alloc]initWithRootViewController:picture];

    


    

    self.viewControllers = @[videoVc,audioVc,pictureVc];

    

   

    

    

}




-(void)createTabbar{

    

    NSArray * ImageArray = @[@"教学研讨-视频_08",@"教学研讨-视频_10",@"教学研讨图文_03"];

    

    NSArray * selectArray = @[@"教学研讨-视频1_08",@"教学研讨-视频1_10",@"教学研讨-图文1_03"];

    

    NSArray * titles = @[@"视频资源",@"音频资源",@"图文资源"];

    

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

        UIImage * orimage = [UIImage imageNamed:ImageArray[i]];

        orimage = [orimage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

        

        UIImage * selectimage = [UIImage imageNamed:selectArray[i]];

        selectimage = [selectimage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

        

        UITabBarItem * item = self.tabBar.items[i];

        item = [item initWithTitle:titles[i] image:orimage selectedImage:selectimage];

        

        

    }

    

    

    [[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateSelected];

    

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值