IOS project development practice-customize the navigation bar and Status Bar background, and develop ios Projects

Source: Internet
Author: User

IOS project development practice-customize the navigation bar and Status Bar background, and develop ios Projects

On the top of the iPhone status bar, there will be a lot of information, such as the operator, signal strength, network status, time, power, and so on. We use a lot of apps, such as QQ, and so on, and we will find that the background or images in the navigation bar have been reset, which will increase the user experience and save the screen space below. How can I set the navigation bar images?

(1) Create an iOS project and select Swift as the language. Drag an image to Images. xcassets and set the size as the background of the top navigation bar.

(2) Select ViewController in Main. storyboard and choose Editor> Embed in> Navigation Controller. Add the top Navigation bar to the interface.

(3) implement the following in the Code:

Import UIKitclass ViewController: UIViewController {override func viewDidLoad () {super. viewDidLoad () initNavBarImg ()} func initNavBarImg () {self. navigationController ?. NavigationBar. setBackgroundImage (UIImage (named: "naviBar"), forBarMetrics: UIBarMetrics. Default) self. navigationController ?. NavigationBar. topItem ?. Title = "" // if the title at the top of the navigation bar is not set, the title will disappear even if it is set in the storyboard. }}

(4) then run the program. The result is as follows: You can see that the top has been set to the desired pattern.


Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.