Theos Tutorials for iOS/UINavigationBar

Object Information edit

This UIKit object is just a regular navigation bar. This wasn't meant to be used by itself as it's included within UINavigationController and UIToolbar. So you'll have to go without a navigation stack if you choose this route. (thanks to DHowett for providing this info.) However, just for informational purposes, it is provided here in case you wanted to create your own class that is dependent on UINavigationBar (whatever that may be.)

Declaring the Bar edit

Create or open an existing Theos project and open the header file to any view controller in your project. In your view controller's header file, you'll want to place the following code:

 @interface RootViewController : UIViewController
 {
     UINavigationBar *navBar; // This is the navigation bar.
 }
 @end

After you add the navigation bar's label, add the declaration of the label.

 @interface RootViewController : UIViewController
 {
     UINavigationBar *navBar; // This is the navigation bar.
     UILabel *myLabel; // This is a label that the navigation bar wil hold
 }
 @end

Now that we have our navigation bar and our label declared in the header, it's time to define them in the implementation file(.h).

Defining the Bar edit

Now that we have the navigation bar declared, it's time to define it. Now let's start by opening the implementation of your project (in this case, it's RootViewController.mm). In the implementation file, we will start by adding two blank lines in between the brackets and placing the following code:

<syntaxhighlight lang="objc">

</syntaxhighlight> - ReverseEffect