Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6554235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:40:33+00:00 2026-05-25T12:40:33+00:00

I’m currently trying to create a custom navigation-bar for my navigation-controller in iOS using

  • 0

I’m currently trying to create a custom navigation-bar for my navigation-controller in iOS using MonoTouch. The application I’m developing has the need to have a single string available on-screen no matter where you are on the application, and I wan’t to achieve something like this (I know this is a little out off proportion, but you should be able to get the point):

+-----------------------------------------+
|  /---------|                     +---+  |
| /   Back   |     Controller Name |btn|  |
|  \---------|                     +---+  |
+-----------------------------------------+
|     Current building <- global string   |
+-----------------------------------------+

The bottom bar should be as small as possible (while not being hard to read), and the original navigation-bar might need to be a tiny bit smaller than normal.

Also, I’ve tried not to use the designer, but to write all the UI-code myself, but if that is impossible to achieve this, then I’ll off cause have to use the designer. Currently I’ve found a project for creating a custom UINavigationBar in MonoTouch, but I have no idea of how to apply that to my NavigationController (see as the NavigationBar-property is read-only). The project I was talking about can be found here: https://github.com/mafis/Monotouch-Custom-Control/tree/master/CustomControls. Also, I would like the design of the actual navigationbar (the top part) to be standard iOS design, and work as a navigationbar normally would.

Any hints, or pointers at how to do this would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:40:34+00:00Added an answer on May 25, 2026 at 12:40 pm

    This is how I ended up solving this problem. I subclassed UIViewController like this:

    using System;
    using MonoTouch.UIKit;
    using MonoTouch.CoreGraphics;
    using System.Drawing;
    using System.Collections.Generic;
    using FdvWeb.Core;
    namespace FdvWeb
    {
        [MonoTouch.Foundation.Preserve(AllMembers=true)]
        public class MainNavigationController : UINavigationController
        {
            private const float NAV_BAR_HEIGHT = 44;
            private readonly float buildingBarTop = 44;
            private readonly float buildingBarHeight = 17;
            private readonly float viewOffset;
    
            private readonly HashSet<UIViewController> modifiedViewControllers = new HashSet<UIViewController>();
    
            UITextView buildingTextView;
    
            [MonoTouch.Foundation.Preserve]
            public MainNavigationController ()
            {
                viewOffset = buildingBarTop + buildingBarHeight - NAV_BAR_HEIGHT;
    
                var tt = new UITextView (new RectangleF (0, buildingBarTop, 320, buildingBarHeight));
    
                NavigationBarHidden = false;
                NavigationBar.AddSubview (tt);
                tt.Font = UIFont.BoldSystemFontOfSize (12);
                tt.TextAlignment = UITextAlignment.Center;
                tt.TextColor = UIColor.LightTextColor;
                tt.BackgroundColor = UIColor.ViewFlipsideBackgroundColor;
                tt.Editable = false;
                tt.ContentInset = new UIEdgeInsets (-9, 0, 0, 0);
                buildingTextView = tt;
            }
    
            public override void ViewDidLoad ()
            {
                base.ViewDidLoad ();
    
    
            }
    
            public override void ViewWillAppear (bool animated)
            {
                base.ViewWillAppear (animated);
            }
    
            public string BuildingText
            {
                get {
                    return buildingTextView.Text;
                }
                set {
                    container.Resolve<IUIThreadDispatcher> ().DispatchOnUIThread (delegate { // Run on UI thread
                        buildingTextView.Text = value;
                    });
                }
            }
    
            public override void PushViewController (UIViewController viewController, bool animated)
            {
                if (!modifiedViewControllers.Contains (viewController))
                {
                    viewController.View = new PaddedView (viewController.View, new InnsetF (0, viewOffset, 0, 0));
                    modifiedViewControllers.Add (viewController);
                }
    
                viewController.NavigationItem.RightBarButtonItem = pickBuildingItem;
                base.PushViewController (viewController, animated);
            }
    
            private class PaddedView : UIView
            {
                private UIView view;
                private InnsetF innsets;
    
                public PaddedView (UIView view, InnsetF innsets)
                    : base(view.Frame)
                {
                    this.view = view;
                    this.innsets = innsets;
                    this.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                    this.AddSubview (view);
                }
    
                public override void LayoutSubviews ()
                {
                    //apply the insets to the subview
                    view.Frame = new RectangleF (innsets.Left, innsets.Top,
                        Frame.Size.Width - innsets.Left - innsets.Right,
                        Frame.Size.Height - innsets.Top - innsets.Bottom);
                }
            }
    
            private class InnsetF
            {
                private float top, bottom, left, right;
                public InnsetF (float left, float top, float right, float bottom)
                {
                    this.top = top;
                    this.left = left;
                    this.bottom = bottom;
                    this.right = right;
                }
    
                public float Top
                {
                    get { return top; }
                    set { top = value; }
                }
    
                public float Bottom
                {
                    get { return bottom; }
                    set { bottom = value; }
                }
    
                public float Right
                {
                    get { return right; }
                    set { right = value; }
                }
    
                public float Left
                {
                    get { return left; }
                    set { left = value; }
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.