Customizing Navigation Bar and Status Bar

Like many of you, I have been very busy upgrading my apps to make them fit for iOS 7. The latest version of iOS introduces lots of visual changes. From a developer’s perspective, the navigation bar and status bar are two noticeable changes that need to cater. The status bar is now transparent, that means the navigation bar behind it shows through. In some cases, the background image for a navigation bar can extend up behind the status bar.

Some time ago, I’ve written a tutorial about how to customize a navigation bar. I think it’s time to revisit the customization and see how it is done in iOS 7. Here are some of the tips and tricks that you’ll find in this article:

  • Setting the background color of navigation bar
  • Using background image in navigation bar
  • Customizing the color of back button
  • Changing the font of navigation bar title
  • Adding multiple bar button items
  • Changing the style of status bar
  • Hiding the status bar
custom navigation bar iOS 7

You’ll need Xcode 5 to properly execute the code as presented in this tutorial. So if you’re still using older versions of Xcode, make sure you upgrade to Xcode 5 before running the sample Xcode project.

Default Navigation Bar in iOS 7

Before we go in to the customization, let’s first take a look at the default navigation bar generated by Xcode 5 and iOS 7. Simply create a Xcode project using Single View Controller template. Embed the view controller in a navigation controller. If you don’t want to start from scratch, you can just download this sample Xcode project.

Xcode 5 bundles both iOS 6 and iOS 7 Simulators. Try to run the sample project using both versions of Simulators.

Default Navigation Bar

As you can see, the navigation bar in iOS 7 is by default intertwined with the status bar. The default color is also changed to light gray, as well.

Changing the Background Color of Navigation Bar

In iOS 7, the tintColor property is no longer used for setting the color of the bar. Instead, use the barTintColor property to change the background color. You can insert the below code in the didFinishLaunchingWithOptions: of AppDelegate.m.

Here is the result:

Change Navigation Bar Background Color

Normally you want to use your own color as the system color doesn’t look nice. Here is a very useful macro for setting RGB color:

Simply put it somewhere at the beginning of AppDelegate.m and use it to create any UIColor object with whatever RGB color you want. Below is an example:

By default, the translucent property of navigation bar is set to YES. Additionally, there is a system blur applied to all navigation bars. Under this setting, iOS 7 tends to desaturate the color of the bar. Here are the sample navigation bars with different translucent setting.

Navigation Bar Translucent

To disable the translucent property, you can simply select the navigation bar in Storyboard. Under Attribute Inspectors, uncheck the translucent checkbox.

Storyboard Navigation Bar Translucent

Using Background Image in Navigation Bar

If your app uses a custom image as the background of the bar, you’ll need to provide a “taller” image so that it extends up behind the status bar. The height of navigation bar is changed from 44 points (88 pixels) to 64 points (128 pixels).

You can still use the setBackgroundImage: method to assign a custom image for the navigation bar. Here is the line of code for setting the background image:

The sample Xcode project bundles two different background images: nav_bg.png and nav_bg_ios7.png. Try to test them out.

Navigation Bar Background Image

Changing the Font of Navigation Bar Title

Just like iOS 6, you can customize the text style by using the “titleTextAttributes” properties of the navigation bar. You can specify the font, text color, text shadow color, and text shadow offset for the title in the text attributes dictionary, using the following text attribute keys:

  • UITextAttributeFont – Key to the font
  • UITextAttributeTextColor – Key to the text color
  • UITextAttributeTextShadowColor – Key to the text shadow color
  • UITextAttributeTextShadowOffset – Key to the offset used for the text shadow

Here is the sample code snippets for altering the font style of the navigation bar title:

If you apply the change to the sample app, the title of navigation bar should look like this:

Custom Navigation Bar Title

Customizing the Color of Back button

In iOS 7, all bar buttons are borderless. The back button is now a chevron plus the title of the previous screen (or just displays ‘Back’ as the button title if the title of the previous screen is nil). To tint the back button, you can alter the tintColor property, which provides a quick and simple way to skin your app with a custom color. Below is a sample code snippet:

In addition to the back button, please note that the tintColor property affects all button titles, and button images.

Custom Back Button Color

If you want to use a custom image to replace the default chevron, you can set the backIndicatorImage and backIndicatorTransitionMaskImage to your image.

The color of the image is controlled by the tintColor property.

Chevron replacement iOS 7

Use Image as Navigation Bar Title

Don’t want to display the title of navigation bar as plain text? You can replace it with an image or a logo by using a line of code:

We simply change the titleView property and assign it with a custom image. This is not a new feature in iOS 7. The code also applies to lower versions of iOS.

Custom Navigation Title Image

Adding Multiple Bar Button Items

Again, this tip is not specifically for iOS 7. But as some of you have raised such question before, I decide to put the tip in this tutorial. From time to time, you want to add more than one bar button item on one side of the navigation bar. Both the leftBarButtonItems and rightBarButtonItems properties lets you assign custom bar button items on the left/right side of the navigation bar. Say, you want to add a camera and a share button on the right side of the bar. You can use the following code:

Here is the sample result:

Add Multiple Bar Button Items

Changing the Style of Status Bar

In older versions of iOS, the status bar was always in black style and there is not much you can change. With the release of iOS 7, you’re allowed to change the appearance of the status bar per view controller. You can use a UIStatusBarStyle constant to specify whether the status bar content should be dark or light content. By default, the status bar displays dark content. In other words, items such as time, battery indicator and Wi-Fi signal are displayed in dark color. If you’re using a dark background in navigation bar, you’ll end up with something like this:

Dark Navigation Bar

In this case, you probably need to change the style of status bar from dark to light. There are two ways to do this. In iOS 7, you can control the style of the status bar from an individual view controller by overriding the preferredStatusBarStyle:

For the sample app, simply put the above code in the RecipeNavigationController.m and the status bar will display light content.

Dark Navigation Bar Light Status Bar

The method introduced above is the preferred way to change the status bar style in iOS 7. Alternatively, you can set the status bar style by using the UIApplication statusBarStyle method. But first you’ll need to opt out the “View controller-based status bar appearance”. Under the Info tab of the project target, insert a new key named “View controller-based status bar appearance” and set the value to NO.

View Controller-based Status Bar

By disabling the “View controller-based status bar appearance”, you can set the status bar style by using the following code:

Hiding the Status Bar

In any case you want to hide the status bar, you can override the prefersStatusBarHidden: in your controller:

Summary

iOS 7 presents developers with new freedom to customize the appearance of navigation bar and status bar. If you’re porting the app from iOS 6 to iOS 7 or creating a brand-new app for iOS 7, I hope you’ll find these tips useful.

For your complete reference, you can download the source code of the demo project from here. Just uncomment any code snippets in the sample project to test out the change.

Like many of you, I’m still exploring all the new changes of iOS 7 SDK. I am by no means an expert on iOS 7. If you find any errors in the article, please do let me know. If you find any tips and tricks related to navigation bar and status bar, please also share with us by leaving comment below.

煤矿破碎车间建设方案(含工艺流程图).docx 煤矿破碎车间建设方案(含工艺流程图) 立即下载

相关推荐

王堃阳.企业表达实战26讲第二辑.pdf

王堃阳.企业表达实战26讲第二辑

Customizing Navigation Bar and Status Bar in iOS 7

RZMars个人Blog地址: http://www.rzmars.com (转载于simon ng 的教程) Like many of you, I have been very busy upgrading my apps to make them fit for iOS 7. The latest version of iOS introduces lots of vis

RZMars的专栏 2378

销售述职PPT制作要点(含数据图表设计).docx

销售述职PPT制作要点(含数据图表设计)

Customizing Navigation Bar and Status Bar in iOS 7 .

[+] Default Navigation Bar in iOS 7Changing the Background Color of Navigation BarUsing Background Image in Navigation BarChanging the Font of Navigation Bar TitleCustomizing the Color of Back butt

西北风的专栏 1852

永磁同步电机多参数辨识仿真【电阻、电感、磁链】(Simulink仿真实现)

内容概要:本文围绕基于Simulink的永磁同步电机多参数辨识仿真展开研究,重点探讨了电机关键参数(如定子电阻、d/q轴电感及永磁体磁链)的在线辨识方法。通过构建基于递推最小二乘法(RLS)的参数估计算法模型,在Simulink环境中实现了对电机内部参数的动态、高精度识别。该仿真体系不仅提升了电机控制系统建模的准确性,还为高性能控制策略(如磁场定向控制FOC、最大转矩电流比MTPA控制、弱磁控制等)提供了可靠的参数支撑,具有良好的工程实用性与技术延展性。; 适合人群:具备电机控制理论基础与Simulink仿真能力,从事电气工程、自动化、新能源驱动系统等相关领域的科研人员、高校研究生及工业界研发工程师。; 使用场景及目标:①掌握永磁同步电机关键参数的实时辨识原理与实现方法;②构建高保真度电机仿真模型以支持先进控制算法的设计与验证;③为无传感器控制、故障诊断、系统自适应调节与性能优化提供精确的参数依据; 阅读建议:建议结合Simulink仿真模型与算法理论同步学习,重点关注RLS算法的实现流程、激励信号设计、噪声抑制处理及参数收敛性分析,并可通过调整负载工况或电机参数进行对比实验,深入理解辨识过程的动态响应特性与鲁棒性表现。

【电磁学,向量场理论和Maxwell方程】二维FDTD(有限差分时域)解决完全电导体边界条件问题研究(Matlab代码实现)

【电磁学,向量场理论和Maxwell方程】二维FDTD(有限差分时域)解决完全电导体边界条件问题研究(Matlab代码实现)内容概要:本文围绕电磁学、向量场理论和Maxwell方程,研究了二维有限差分时域(FDTD)方法在完全电导体(PEC)边界条件下的应用,并提供了基于Matlab的代码实现。文中详细阐述了FDTD算法的基本原理,重点解决了电磁波在PEC边界上的反射特性建模问题,通过离散化Maxwell旋度方程构建时空域迭代过程,实现了对电磁场分布的动态仿真。同时,结合边界条件处理技术,确保了电场切向分量在导体表面为零的物理约束得以满足,提升了仿真精度与稳定性。; 适合人群:具备电磁场与波基础理论知识,熟悉Matlab编程,从事电磁仿真、天线设计或计算电磁学相关研究的研究生及科研人员。; 使用场景及目标:①掌握FDTD方法在电磁仿真中的核心实现流程;②理解PEC边界条件在数值计算中的处理方式;③为复杂电磁环境建模如雷达散射截面(RCS)分析、微波器件仿真等提供技术基础与代码参考; 阅读建议:建议读者结合Maxwell方程组的物理意义与差分格式的数学推导,逐步调试Matlab代码,观察不同边界条件下电场与磁场的传播行为,加深对数值稳定性(如CFL条件)和边界效应的理解。

uni-app + LiveKit:iOS 整屏共享从 0 到可用(Broadcast Extension 实战)

运行→运行到手机或模拟器→制作自定义调试基座勾选包含 LiveKit 会议能力的 UTS 插件(如)以及项目用到的其它 UTS 插件使用云端证书/描述文件打包 iOS 基座安装到真机后,再用该基座运行项目系统要求独立 Broadcast Extension扩展不会随 UTS 源码自动编译云打包对手动描述文件非常严格把这三件事打通后,「当前安装包未配置整屏共享」基本就会消失。

FinelyYang的专栏 225

基于可行性约束一致化的A星算法RRT星算法与粒子群优化比较研究(Matlab代码实现)

内容概要:本文系统性地研究了基于可行性约束一致化的A星算法、RRT星算法与粒子群优化算法在路径规划领域的性能对比,并提供了完整的Matlab代码实现。研究通过统一的环境建模与可行性约束处理框架,对三种算法在复杂约束条件下的路径搜索效率、路径质量、计算耗时及鲁棒性等方面进行了全面比较分析,尤其聚焦于其在无人机三维路径规划中的应用表现。文中深入阐述了各算法的核心原理、约束处理机制及其优化策略,并通过仿真实验展示了不同算法在应对静态与动态障碍物时的规划效果,为相关领域的算法选型与优化提供了坚实的理论依据和技术支持。 适合人群:具备一定算法基础和Matlab编程能力的硕士、博士研究生及科研人员,以及从事无人机、机器人、智能交通等领域路径规划工作的工程技术人员。 使用场景及目标:①为智能体路径规划任务提供主流算法的性能对比基准;②指导研究人员根据具体应用场景(如实时性要求、环境复杂度、路径平滑性需求)选择最合适的路径规划算法;③作为教学与科研中算法实现与仿真实验的参考案例。 阅读建议:建议读者结合提供的Matlab代码进行实践操作,复现文中的仿真实验结果,并尝试在不同环境参数下测试各算法的性能变化,以加深对算法特性的理解;同时可进一步扩展研究范围,引入其他智能优化算法进行对比分析。

flutter 打包IOS并上架到apple store(Android Studio)

ios/Runner/info.plist,修改CFBundleVersion和CFBundleShortVersionString。至此,XCode上传成功,打开Apple Store后台。然后等待打包完成,等待期间可以进行第二步,应用市场更新。点击完成后,输入本次更新的其他内容,即可点击提交审核。pubspec.yaml,修改Version。2.讲flutter代码更新到IOS模块。3.打开xcode,确定版本是否修改。版本号确定好后,准备打包;输入版本信息和更新信息。

米枔的博客 177

基于一致渐近克拉美罗下界的效用优化本地差分隐私估计极限分析(Matlab代码实现)

内容概要:本文聚焦于“基于一致渐近克拉美罗下界(Cramér-Rao Lower Bound, CRLB)的效用优化本地差分隐私估计极限分析”,结合Matlab代码实现,系统研究在本地差分隐私(Local Differential Privacy, LDP)机制下如何通过理论建模与数值仿真手段优化隐私保护与数据效用之间的权衡关系。研究以一致渐近CRLB为核心性能指标,定量评估不同隐私扰动机制对参数估计精度的理论下限影响,进而提出面向离散分布估计的隐私预算分配策略与效用优化方法,旨在提升受保护数据的可用性与统计有效性。内容涵盖隐私机制建模、CRLB推导、估计效率分析、最优扰动设计等关键环节,适用于对隐私-preserving数据发布、分布式学习与敏感信息统计分析有高要求的应用场景。; 适合人群:具备扎实的统计学、信息论与差分隐私理论基础,熟悉Matlab编程环境,从事数据安全、机器学习、信号处理或隐私保护相关研究的研究生、博士生及科研人员。; 使用场景及目标:① 精确刻画本地差分隐私下的参数估计性能理论极限;② 设计兼具强隐私保障与高效数据效用的隐私保护机制;③ 利用CRLB理论指导隐私算法的优化设计与实验验证;④ 推动差分隐私技术在敏感数据统计、联邦学习、物联网数据共享等实际系统中的可信应用; 阅读建议:建议读者结合提供的Matlab代码深入理解CRLB的数学推导与数值计算过程,重点剖析隐私机制与Fisher信息矩阵之间的映射关系,并通过仿真实验验证理论边界的有效性,同时可参考文中涉及的路径规划、优化算法等交叉研究以拓展技术视野。

基于超螺旋滑模观测器的永磁同步电机无位置传感器控制仿真模型(Simulink仿真实现)

内容概要:本文介绍了一种基于超螺旋滑模观测器(Super-Twisting Sliding Mode Observer, STSMO)的永磁同步电机(PMSM)无位置传感器控制仿真模型,采用Simulink工具构建完整的控制系统,实现了对电机转子位置与速度的高精度估计,从而在无需物理位置传感器的条件下完成高性能闭环控制。该方法融合了滑模控制的强鲁棒性与超螺旋算法的优越特性,有效抑制了传统滑模观测器中存在的高频抖振问题,提升了系统在动态响应、抗干扰能力及稳态精度方面的表现,适用于从低速到高速的全速域运行场景。模型涵盖了电机本体、坐标变换、电流环控制、观测器设计、转速估算与反馈控制等关键模块,具有良好的工程参考价值和科研教学意义。; 适合人群:具备自动控制理论、现代控制方法、电机驱动系统基础及相关仿真经验的研究生、科研人员,以及从事电气自动化、新能源汽车、工业伺服系统、航空航天等领域的技术研发工程师。; 使用场景及目标:①用于永磁同步电机无传感器控制技术的研究与教学演示,深入理解非线性观测器的设计原理;②为高可靠性、低成本驱动系统提供无传感解决方案的仿真验证平台;③优化超螺旋滑模观测器参数,研究其在不同工况下的鲁棒性与估计精度;④作为高级控制算法(如自适应、智能控制)融合改进的基础框架; 阅读建议:学习者应熟练掌握Simulink建模流程、滑模控制理论与状态观测器基本原理,建议结合仿真模型逐步调试,对比传统滑模观测器与超螺旋滑模观测器在相同条件下的动态响应与抖振抑制效果,深入分析其在启动、负载扰动、转速突变等典型工况下的性能差异,进而掌握先进滑模控制策略的核心设计理念与工程实现技巧。

iOS 27 适配指南:Xcode 27 升级、UIScene 生命周期迁移及游戏项目兼容性处理

本文详细介绍 iOS 27 和 Xcode 27 的适配要求,重点讲解 UIScene 生命周期迁移、SceneDelegate 创建、Info.plist 配置、LaunchScreen 启动屏幕、UIWindow 获取方式及第三方 SDK 回调适配,并针对传统 Objective-C、Cocos2d-x 游戏项目提供静态库架构兼容、签名打包及测试方案,帮助开发者完成 iOS 27 适配和 App Store 提交。

u010207898的博客 363

HDR标准核心参数全解析:从PQ/HLG到元数据,一篇搞懂技术选型

本文全面解析HDR标准的核心参数,包括PQ/HLG传输函数和元数据机制,帮助读者理解技术选型的关键因素。通过对比主流HDR标准的技术细节,提供从内容创作到硬件适配的实用指南,助力实现更真实的视觉体验。

weixin_31766003的博客 308

Windows 开发 Objective-C iOS App,用 KXBuild 编译、真机调试和打包 ipa

在 Windows 上开发 Objective-C 的 iOS App,用 KXBuild 打开现有 Xcode 工程就能编译,.xcodeproj、.xcworkspace 和 CocoaPods 工作区都不用改造。USB 连 iPhone 按 F5 编译安装并停在断点,Objective-C 和 Swift 混编也能调。Release 用 Apple Distribution 证书签名生成 ipa,Windows 上用 Appuploader 或 Transporter 上传,全程不需要 Xcode。

2501_91590906的博客 243

晶圆测试(Wafer Sort)的核心技术与良率提升策略

晶圆测试(Wafer Sort)是芯片制造中的关键“入学考试”,通过探针台与自动测试设备(ATE)对晶圆上的芯片进行功能与参数测试,筛选不合格芯片以控制成本。本文深入解析了其核心技术,包括自动化视觉系统对准、测试流程优化策略,并探讨如何利用测试数据驱动良率提升,展望了DFT与AI智能测试的未来趋势。

e4f5g6h的博客 533

【开发必备插件】iframe嵌套报“拒绝连接请求”的本地解决方法

关键词:iframe 拒绝连接、X-Frame-Options、Chrome 插件、前端调试、Allow X-Frame-Options前几天我在本地项目里调试一个第三方网站的嵌入页面时,遇到了一个非常经典的报错:xxx.com 拒绝了我们的连接请求。熟悉的老前端们一眼就知道——这是。但对于日常开发来说,我们经常需要在本地测试 iframe 嵌套外部页面(比如嵌第三方登录页、支付页、可视化报表系统等)。而线上站点配置了或DENY时,就会直接导致 iframe 加载失败。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 1561

如何使用Xcode Instruments分析iOS应用内存使用情况

这篇文章全面讲解了在iOS开发中,利用Xcode Instruments工具进行内存使用情况分析的全过程,包括打开Instruments、选择Allocations模板、配置选项、记录数据、分析内存分配和泄漏检测,以及性能优化建议。

2501_91373349的博客 194

用 CL_ABAP_ZIP 在 ABAP 里打包任意文件:从前端多选到 ZIP 交付的一条龙实践

本文介绍了在SAP ABAP中实现文件打包交付的完整解决方案。文章首先区分了ZIP和GZIP的不同用途:ZIP用于多文件归档,GZIP用于单数据流压缩。核心流程包括四个步骤:文件选择、二进制上传、内存打包和ZIP输出,并提供了关键对象与函数的速查表。针对实际项目中常见的乱码、大文件处理等问题给出了解决方案,最后展示了一个完整的可运行示例代码,涵盖了从文件选择到下载的全流程实现。该方案适用于财务、质量、运维等多种业务场景,能够有效解决多文件交付的最后一公里问题。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 225
上一篇: go client http post upload上传及 server 参数获取
下一篇: Unable to update index for central
weixin_34150503
博客等级 码龄11年 4543粉丝 153原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值