在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1.导航栏外观设定 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { //.导航栏 var navBar=UINavigationBar.appearance() //.设置导航栏标题颜色 navBar.titleTextAttributes = [ NSForegroundColorAttributeName : UIColor.whiteColor()] //.设置导航栏按钮颜色 navBar.tintColor = UIColor.whiteColor() //.设置导航栏背景颜色 navBar.barTintColor=UIColor(red: 49.0/255.0, green: 183.0/255.0, blue: 235.0/255.0, alpha: 1.0) return true } 2.让状态栏显示白色 *让launch页面启动时状态栏显示黑色 在plist文件中设定键:Status bar style 值:Gray style (default) *让App应用程序的状态栏显示白色 在plist文件中设定键:View controller-based status bar appearance 值:NO 在AppDelegate.swift文件中的didFinishLaunchingWithOptions方法添加以下代码 UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
3.建一个tabbarController 三个navigationController 三个ViewController 4.将SliderViewController文件中的initSubViews后面添加代码: //用mainContentView装下MainTab var mainTabVC: UITabBarController! = self.storyboard!.instantiateViewControllerWithIdentifier("MainTabViewController") as UITabBarController mainContentView.addSubview(mainTabVC.view) 5.MessageViewController(消息),添加导航栏控件代码:
override func viewDidLoad() { super.viewDidLoad() //左侧显示头像 var photoView:UIImageView=UIImageView(image: UIImage(named: "[email protected]")) photoView.frame=CGRectMake(0, 0, 30, 30) var photoItem:UIBarButtonItem=UIBarButtonItem(customView: photoView) self.navigationItem.leftBarButtonItem=photoItem //头像变圆形(设弧度为宽度的一半) photoView.clipsToBounds=true photoView.layer.cornerRadius=photoView.bounds.width*0.5 //设置titleView为 var titleSegment=UISegmentedControl(items: ["消息", "电话"]) titleSegment.selectedSegmentIndex=0 self.navigationItem.titleView=titleSegment //左侧一按钮 var rightButton:UIButton=UIButton() rightButton.frame=CGRect(origin:CGPointZero, size: CGSize(width: 26, height: 26)) rightButton.setBackgroundImage(UIImage(named: "menu_icon_bulb.png"), forState: UIControlState.Normal); var rightItem:UIBarButtonItem=UIBarButtonItem(customView: rightButton) self.navigationItem.rightBarButtonItem=rightItem }
最终效果: |
请发表评论