step1:自定义一个类  NTViewController,该类继承UITabBarController:

//
// NTViewController.swift
// Housekeeper
//
// Created by 卢洋 on 15/10/20.
// Copyright © 2015年 奈文摩尔. All rights reserved.
// import Foundation
import UIKit
class NTViewController:UITabBarController{ var items=[];
//页面初始化
override func viewDidLoad() {
super.viewDidLoad();
//1.创建首页导航控制器
let vwIndex=index();
let navIndex=UINavigationController(rootViewController: vwIndex);
navIndex.title="首页";
     //设置工具栏默认显示的图片
navIndex.tabBarItem.image=UIImage(named: "home")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
     //设置工具栏选中后的图片
navIndex.tabBarItem.selectedImage=UIImage(named: "homes.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); //2.创建活动信息导航控制器
let vwActivityInfo=activityInfo();
let navActivityInfo=UINavigationController(rootViewController: vwActivityInfo);
navActivityInfo.title="活动信息";
navActivityInfo.tabBarItem.image=UIImage(named: "Activity-information.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
navActivityInfo.tabBarItem.selectedImage=UIImage(named: "Activity-informations.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); //3.创建车辆展示导航控制器
let vwCarDisplay=carDisplay();
let navCarDisplay=UINavigationController(rootViewController: vwCarDisplay);
navCarDisplay.title="车辆展示";
navCarDisplay.tabBarItem.image=UIImage(named: "Vehicle-display.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
navCarDisplay.tabBarItem.selectedImage=UIImage(named: "Vehicle-displays.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); //4.创建个人中心导航控制器
let vwPersonalCenter=personalCenter();
let navPersonalCenter=UINavigationController(rootViewController: vwPersonalCenter);
navPersonalCenter.title="个人中心";
navPersonalCenter.tabBarItem.image=UIImage(named: "Personal-Center.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
navPersonalCenter.tabBarItem.selectedImage=UIImage(named: "Personal-Centers.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); //5.添加到工具栏
items=[navIndex,navActivityInfo,navCarDisplay,navPersonalCenter];
self.viewControllers=items as? [UIViewController];
self.navigationController?.navigationBar.tintColor=UIColor.whiteColor(); //6.自定义工具栏
self.tabBar.backgroundColor=UIColor.clearColor();
//底部工具栏背景颜色
self.tabBar.barTintColor=UIColor.appMainColor(); //7.设置底部工具栏文字颜色(默认状态和选中状态)
UITabBarItem.appearance().setTitleTextAttributes(NSDictionary(object:UIColor.whiteColor(), forKey:NSForegroundColorAttributeName) as? [String : AnyObject], forState:UIControlState.Normal);
UITabBarItem.appearance().setTitleTextAttributes(NSDictionary(object:UIColor.blueWithTabbar(), forKey:NSForegroundColorAttributeName) as? [String : AnyObject], forState:UIControlState.Selected) } }

step2:打开 AppDelegate.swift

//
// AppDelegate.swift
// Housekeeper
//
// Created by 卢洋 on 15/10/14.
// Copyright © 2015年 奈文摩尔. All rights reserved.
// import Foundation
import UIKit @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// 应用程序启动后
//1.声明一个空视图
self.window = UIWindow(frame: UIScreen.mainScreen().bounds);
self.window!.backgroundColor=UIColor.whiteColor(); //2.1导航背景颜色
UINavigationBar.appearance().barTintColor=UIColor.appMainColor(); UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(CGFloat(NSInteger.min),CGFloat(NSInteger.min)), forBarMetrics:UIBarMetrics.Default);
//2.2导航标题文字颜色
UINavigationBar.appearance().titleTextAttributes=NSDictionary(object:UIColor.whiteColor(), forKey:NSForegroundColorAttributeName) as? [String : AnyObject];

     //楼主的状态栏颜色改变了,设置为了白色,如果有需要,打开 info.plist  增加Key(View controller-based status bar appearance,Value为 no
//2.3将状态栏变为白色
UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent; //2.4设置返回按钮颜色
UINavigationBar.appearance().tintColor=UIColor.whiteColor(); //3.指定根视图
let rootView=NTViewController();
self.window!.rootViewController=rootView;
self.window!.makeKeyAndVisible(); return true
} func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
} func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
} func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
} func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
} func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} }

效果图如下:中间显示的内容是我的项目,你们忽略不计就好了,哈哈。

swift-UINavigationController纯代码自定义导航控制器及底部工具栏的使用的更多相关文章

  1. swift UITabelVIew - 纯代码自定义tabelViewCell

    // //  CustomTableViewCell.swift //  tab // //  Created by su on 15/12/7. //  Copyright © 2015年 tian ...

  2. AJ学IOS 之微博项目实战(2)微博主框架-自定义导航控制器NavigationController

    AJ分享,必须精品 一:添加导航控制器 上一篇博客完成了对底部的TabBar的设置,这一章我们完成自定义导航控制器(NYNavigationController). 为啥要做自定义呢,因为为了更好地封 ...

  3. ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局

    本文转自 :http://www.cnblogs.com/wendingding/p/3761730.html ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布 ...

  4. iOS彩票项目--第一天,自定义TabBar控制器和自定义TabBar,自定义导航控制器

    一.环境配置,和项目层次搭建 二.自定义TabBar 项目中TabBar中的导航按钮美工给的图片太大,图片中包含了图片和文字.最主要的是TabBar上面的按钮图片尺寸是有规定的,当高度大于44的时候, ...

  5. iOS开发小技巧--纯代码自定义cell

    纯代码自定义cell 自定义cell的步骤(每个cell的高度不一样,每个cell里面显示的内容也不一样) 1.新建一个继承自UITableViewCell的子类 2.在initWithStyle:方 ...

  6. IOS开发之——自定义导航控制器

    BasicNavigationViewController:UINavigationViwController /* 隐藏导航底部线条 */ -(void)viewDidLoad{    [super ...

  7. IOS开发之功能模块--自定义导航控制器类常用自定义的代码

    前言:本文篇幅不多,但是涉及到的内容却是开发中常用的. 涉及的内容: 1.统一设置导航控制器子控制器的返回按钮. 2.因为修改了系统的返回按钮,所以还需要设置手势事件. 3.隐藏底部的工具条. 这里直 ...

  8. swift 之 纯代码创建 cell

    初学swift 但是网上只有很多swift用xib创建的cell,就算是有也不是我想要的.今天自己弄了一个不用xib纯代码写的,来上代码 博客地址: https://github.com/liguol ...

  9. AJ学IOS(17)UI之纯代码自定义Cell实现新浪微博UI

    AJ分享,必须精品 先看效果图 编程思路 代码创建Cell的步骤 1> 创建自定义Cell,继承自UITableViewCell 2> 根据需求,确定控件,并定义属性 3> 用get ...

随机推荐

  1. Oracle移除表空间的数据文件 ora-00604 ora-01426

     项目背景:在之前开发环境数据库管理比較乱,在表空间不足时仅仅是加入数据文件,測试完后数据己删除,但数据库表空间所占的空间不能回收,导致数据库的存储文件夹使用率达到97%以上实际使用仅仅有10%, ...

  2. window+nginx+php-cgi的php-cgi线程/子进程问题

    见bbs http://bbs.csdn.net/topics/390803643/close 正常的配置情况下,window的php-cgi是不会出现多线程/子进程的,例如以下配置 fastcgi_ ...

  3. 用VBS控制鼠标(获取鼠标坐标、鼠标移动、鼠标单击、鼠标双击、鼠标右击)

    Demon's Blog 忘记了,喜欢一个人的感觉 Demon's Blog  »  程序设计  »  用VBS控制鼠标(获取鼠标坐标.鼠标移动.鼠标单击.鼠标双击.鼠标右击) « bbPress积分 ...

  4. linux驱动之设备号与创建设备节点

    设备号: 1.自己主动分配 major = register_chrdev(0,"first_drv",&first_sdv_fops);//注冊 注冊设备时给设备号写0, ...

  5. oc70--NSArray1

    // // main.m // NSArray是不可变的,一旦初始化完毕,就不能添加和删除了.类似于NSString和NSMutilString. #import <Foundation/Fou ...

  6. 神经网络的结构汇总——tflearn

    一些先进的网络结构: # https://github.com/tflearn/tflearn/blob/master/examples/images/highway_dnn.py # -*- cod ...

  7. git-更改本地和远程分支的名称

    git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the ...

  8. vue项目打包之后首页白屏的问题

    本地的vue项目在server端浏览没问题,但是执行npm run build 打包之后在本地预览是白屏. 解决方法 1.路径问题 在config文件夹中找到index.js打开把assetsPubl ...

  9. springAOP注解方式定义切入点报错error at ::0 can't find referenced pointcut

    [说明] 1.使用spring版本:4.0.4 2.springAOP相关依赖包: 1)aopalliance-1.0.jar 2)aspectjweaver-1.8.9.jar 3)aspectjr ...

  10. D. Toy Sum(cf)

    http://codeforces.com/problemset/problem/405/D 题意:已知集合S={1,2,3......1000000},s=1000000,从集合S中选择n个数,X= ...