<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TabBar &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/tabbar/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Tue, 19 Aug 2025 15:38:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>4 Setting the Badge Color for Tabs on iOS</title>
		<link>https://blog.xojo.com/2025/08/20/4-setting-the-badge-color-for-tabs-on-ios/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Wed, 20 Aug 2025 14:00:00 +0000</pubDate>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Declares]]></category>
		<category><![CDATA[Navigation Bar]]></category>
		<category><![CDATA[TabBar]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=15208</guid>

					<description><![CDATA[This is the final article in our series on customizing the appearance of the NavigationBar and TabBar. In this post, we’ll go a step further&#8230;]]></description>
										<content:encoded><![CDATA[
<p>This is the final article in our series on customizing the appearance of the <code>NavigationBar</code> and <code>TabBar</code>. In this post, we’ll go a step further and show how to change the default color of the tab badge which is red by default.</p>



<p>As you might expect, we’ll need a few more Declares to accomplish this. Continue reading to learn how!</p>



<span id="more-15208"></span>



<p>Since we’re building on the example project from the first blog post in this series, I strongly recommend completing that post if you haven’t already, then continuing with the second and third articles before proceeding here.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img fetchpriority="high" decoding="async" width="706" height="202" src="https://blog.xojo.com/wp-content/uploads/2025/07/Screenshot-2025-07-29-at-2.33.33-PM.png" alt="" class="wp-image-15209" srcset="https://blog.xojo.com/wp-content/uploads/2025/07/Screenshot-2025-07-29-at-2.33.33-PM.png 706w, https://blog.xojo.com/wp-content/uploads/2025/07/Screenshot-2025-07-29-at-2.33.33-PM-300x86.png 300w" sizes="(max-width: 706px) 100vw, 706px" /></figure>
</div>


<p>Select the &#8220;DeclaresForiOS&#8221; module and add a new method to it, using the following values for its signature in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> <code>TabBarBadgeColor</code></li>



<li><strong>Parameters:</strong> Extends tab As <code>iOSTabBar</code>, Assigns value As <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Global</li>
</ul>



<p>And put the following snippet of code in the associated Code Editor:</p>



<pre class="wp-block-code"><code>Var tabController As Ptr = tab.ViewControllerHandle

If value = Nil Then Return

Declare Function GetTabBar Lib "UIKit" Selector "tabBar" (obj As Ptr) As Ptr
Var tabBar As Ptr = GetTabBar(tabController)

Var colorPtr As Ptr = ColorGroupToUIColor(value)

Declare Function BarAppearance Lib "UIKit" Selector "standardAppearance" (obj As Ptr) As Ptr
Declare Sub SetAppearance Lib "UIKit" Selector "setStandardAppearance:" (obj As Ptr, value As Ptr)

Var appearance As Ptr = BarAppearance(tabBar)

Declare Function StackedLayout Lib "UIKit" Selector "stackedLayoutAppearance" (obj As Ptr) As Ptr
Declare Function InlineLayout Lib "UIKit" Selector "compactInlineLayoutAppearance" (obj As Ptr) As Ptr
Declare Function NormalState Lib "UIKit" Selector "normal" (obj As Ptr) As Ptr

Var stackLayout As Ptr = StackedLayout(appearance)
Var inLayout As Ptr = InlineLayout(appearance)
Var normalState As Ptr = NormalState(stackLayout)
Var normalInlineState As Ptr = NormalState(inLayout)

Declare Sub SetBadgeColor Lib "UIKit" Selector "setBadgeBackgroundColor:" (obj As Ptr, value As Ptr)

SetBadgeColor(normalState, colorPtr)
SetBadgeColor(normalInlineState, colorPtr)

SetAppearance(tabBar, appearance)

If System.Version.MajorVersion &gt;= 15 Then
  Declare Sub SetScrollEdgeAppearance Lib "UIKit" Selector "setScrollEdgeAppearance:" (obj As Ptr, value As Ptr)
  SetScrollEdgeAppearance(tabBar, appearance)
End If</code></pre>



<p>Next, select the Screen1 item in the Navigator and add a new property to it using the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> <code>MyTabBadgeColor</code></li>



<li><strong>Type:</strong> <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Protected</li>
</ul>



<h3 class="wp-block-heading">Setting the Badge Text Color</h3>



<p>What’s next? I’m sure you guessed it! Now that we can customize the badge color, the default white text color on the badge may not always provide the best contrast.</p>



<p>Let’s add a new method to our &#8220;DeclaresForiOS&#8221; module with the following signature values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> <code>TabBarBadgeTextColor</code></li>



<li><strong>Parameters:</strong> Extends tab As <code>iOSTabBar</code>, Assigns value As <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Global</li>
</ul>



<p>And type (or paste) the following snippet of code in the associated Code Editor:</p>



<pre class="wp-block-code"><code>Var tabController As Ptr = tab.ViewControllerHandle

If value = Nil Then Return

Declare Function GetTabBar Lib "UIKit" Selector "tabBar" (obj As Ptr) As Ptr
Var tabBar As Ptr = GetTabBar(tabController)

Var colorPtr As Ptr = ColorGroupToUIColor(value)

Declare Function BarAppearance Lib "UIKit" Selector "standardAppearance" (obj As Ptr) As Ptr
Declare Sub SetAppearance Lib "UIKit" Selector "setStandardAppearance:" (obj As Ptr, value As Ptr)

Var appearance As Ptr = BarAppearance(tabBar)

Declare Function StackedLayout Lib "UIKit" Selector "stackedLayoutAppearance" (obj As Ptr) As Ptr
Declare Function InlineLayout Lib "UIKit" Selector "compactInlineLayoutAppearance" (obj As Ptr) As Ptr
Declare Function NormalState Lib "UIKit" Selector "normal" (obj As Ptr) As Ptr

Var stackLayout As Ptr = StackedLayout(appearance)
Var inLayout As Ptr = InlineLayout(appearance)

Var normalState As Ptr = NormalState(stackLayout)
Var normalInlineState As Ptr = NormalState(inLayout)

Declare Sub SetBadgeTextAttr Lib "UIKit" Selector "setBadgeTextAttributes:" (obj As Ptr, value As Ptr)

Declare Function NSClassFromString Lib "Foundation" (name As CFStringRef) As Ptr
Declare Function DictionaryWithObjectForKey Lib "UIKit" Selector "dictionaryWithObject:forKey:" (obj As Ptr, value As Ptr, key As CFStringRef) As Ptr

Var dict As Ptr = DictionaryWithObjectForKey( NSClassFromString("NSMutableDictionary") , colorPtr, "NSColor")

SetBadgeTextAttr(normalState, dict)
SetBadgeTextAttr(normalInlineState, dict)

SetAppearance(tabBar, appearance)

If System.Version.MajorVersion >= 15 Then
  Declare Sub SetScrollEdgeAppearance Lib "UIKit" Selector "setScrollEdgeAppearance:" (obj As Ptr, value As Ptr)
  SetScrollEdgeAppearance(tabBar, appearance)
End If</code></pre>



<p>Next, select the <code>Screen1</code> item in the Navigator and add a new property to it using the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> <code>MyTabBadgeTextColor</code></li>



<li><strong>Type:</strong> <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Protected</li>
</ul>



<p>Then, select the <code>Screen1.Opening</code> event handler and add these lines of code to it:</p>



<pre class="wp-block-code"><code>MyTabBadgeColor = New ColorGroup(Color.Green, Color.Blue)
MyTabBadgeTextColor = New ColorGroup(Color.Black, Color.Yellow)

Me.ParentTabBar.BadgeAt(0) = "33"
Me.ParentTabBar.BadgeAt(1) = "42"</code></pre>



<p>Lastly, select the <code>Screen1.AppearanceChanged</code> event handler and add this line of code at the end:</p>



<pre class="wp-block-code"><code>Me.ParentTabBar.TabBarBadgeColor = MyTabBadgeColor
Me.ParentTabBar.TabBarBadgeTextColor = MyTabBadgeTextColor</code></pre>



<h3 class="wp-block-heading">Testing the App</h3>



<p>Everything is set! Run the app on your iPhone or in the Simulator, and you’ll see each tab in the <code>TabBar</code> displaying its own badge with the custom background and text colors we configured in the Opening Event.</p>



<p>Download the example project from <a href="https://drive.google.com/file/d/1NJ7A3JHf60Fzo23AoY8dLA6m6phFSvpT/view?usp=sharing">this link</a>.</p>



<p>Happy Xojo Coding!</p>



<p><em>Javier Menendez is an engineer at Xojo and has been using Xojo since 1998. He lives in Castellón</em>, <em>Spain and hosts regular Xojo hangouts en español. Ask Javier questions on Twitter at <a href="https://twitter.com/xojoes" target="_blank" rel="noreferrer noopener">@XojoES</a> or on the <a href="https://forum.xojo.com/u/javier_menendez/summary" target="_blank" rel="noreferrer noopener">Xojo Forum</a>.</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>3 Coloring the Tab Bar on iOS</title>
		<link>https://blog.xojo.com/2025/08/19/3-coloring-the-tab-bar-on-ios/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Tue, 19 Aug 2025 15:37:37 +0000</pubDate>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Declares]]></category>
		<category><![CDATA[Navigation Bar]]></category>
		<category><![CDATA[TabBar]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=15195</guid>

					<description><![CDATA[In the first two blog posts, we saw how important it is to customize the NavigationBar when theming your iOS app. However, that’s only part&#8230;]]></description>
										<content:encoded><![CDATA[
<p>In the first two blog posts, we saw how important it is to customize the <code>NavigationBar</code> when theming your iOS app. However, that’s only part of the equation, especially if your app also uses a <code>TabBar</code>. In that case, you&#8217;ll likely want to customize not only the background color of the <code>TabBar</code>, but also the text color of the selected tab and the color used for the unselected tabs.</p>



<p>Continue reading to learn how to do all of this thanks to the powerful flexibility of Declares!</p>



<span id="more-15195"></span>



<p>Before we dive in, keep in mind that we&#8217;re building on the example project introduced in the first blog post of this series. If you haven’t read it yet, I encourage you to start there. Then, follow up with the second post to make sure you&#8217;re fully up to speed and ready to continue adding even more color customization to your iOS screens!</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="704" height="220" src="https://blog.xojo.com/wp-content/uploads/2025/07/TabBar.png" alt="" class="wp-image-15196" srcset="https://blog.xojo.com/wp-content/uploads/2025/07/TabBar.png 704w, https://blog.xojo.com/wp-content/uploads/2025/07/TabBar-300x94.png 300w" sizes="(max-width: 704px) 100vw, 704px" /></figure>
</div>


<h3 class="wp-block-heading">Background Color for the TabBar</h3>



<p>In order to colorize the <code>TabBar</code> background, we need to add a new method to the &#8220;DeclaresForiOS&#8221; Module using the following values:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> <code>TabBarBackgroundColor</code></li>



<li><strong>Parameters:</strong> Extends tab As <code>iOSTabBar</code>, Assigns value As <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Global</li>
</ul>



<p>Add the following snippet of code in the associated Code Editor:</p>



<pre class="wp-block-code"><code>Var tabController As Ptr = tab.ViewControllerHandle

If value = Nil Then Return

Declare Function GetTabBar Lib "UIKit" Selector "tabBar" (obj As Ptr) As Ptr
Var tabBar As Ptr = GetTabBar(tabController)

Var colorPtr As Ptr = ColorGroupToUIColor(value)

Declare Function BarAppearance Lib "UIKit" Selector "standardAppearance" (obj As Ptr) As Ptr
Declare Sub ConfigureWithOpaqueBackground Lib "UIKit" Selector "configureWithOpaqueBackground" (obj As Ptr)
Declare Sub SetBackgroundColor Lib "UIKit" Selector "setBackgroundColor:" (obj As Ptr, value As Ptr)
Declare Sub SetAppearance Lib "UIKit" Selector "setStandardAppearance:" (obj As Ptr, value As Ptr)

Var appearance As Ptr = BarAppearance(tabBar)
SetBackgroundColor(appearance, colorPtr)

SetAppearance(tabBar, appearance)

If System.Version.MajorVersion >= 15 Then
  Declare Sub SetScrollEdgeAppearance Lib "UIKit" Selector "setScrollEdgeAppearance:" (obj As Ptr, value As Ptr)
  SetScrollEdgeAppearance(tabBar, appearance)
End If</code></pre>



<p>Essentially, we’re setting the color by assigning it to the <code>backgroundColor</code> property of the <code>appearance</code> object associated with the <code>TabBar</code>.</p>



<h3 class="wp-block-heading">Setting the Text Color</h3>



<p>Now let’s add the code responsible for setting the text color of the selected tab in the <code>TabBar</code>. To do this, we just need to set the <code>tintColor</code> property. So, go ahead and add a new method to the &#8220;DeclaresForiOS&#8221; module with the following values:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> <code>TabBarTextColor</code></li>



<li><strong>Parameters:</strong> Extends tab As <code>iOSTabBar</code>, Assigns value As <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Global</li>
</ul>



<p>And put the following snippet of code in the associated Code Editor:</p>



<pre class="wp-block-code"><code>Var tabController As Ptr = tab.ViewControllerHandle

If value = Nil Then Return

Declare Function GetTabBar Lib "UIKit" Selector "tabBar" (obj As Ptr) As Ptr
Var tabBar As Ptr = GetTabBar(tabController)

Var colorPtr As Ptr = ColorGroupToUIColor(value)

Declare Sub SetTintColor Lib "UIKit" Selector "setTintColor:" (obj As Ptr, value As Ptr)

SetTintColor(tabBar, colorPtr)</code></pre>



<h3 class="wp-block-heading">Setting Unselected Tabs Text Color</h3>



<p>To set the text color for unselected tabs, we’ll need to use a few additional Declares. This is because the color must be applied to the <em>normal</em> state of the <code>stackedLayoutAppearance</code> object from the TabBar’s appearance. Additionally, we need to set the same value for the <code>compactInlineLayoutAppearance</code>, which is used when the device is in landscape orientation.</p>



<p>Add a new method to the &#8220;DeclaresForiOS&#8221; Module using the following values for its signature:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> <code>TabBarUnselectedTextColor</code></li>



<li><strong>Parameters:</strong> Extends tab As <code>iOSTabBar</code>, Assigns value As <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Global</li>
</ul>



<p>And add the following snippet of code in the associated Code Editor:</p>



<pre class="wp-block-code"><code>Var tabController As Ptr = tab.ViewControllerHandle

If value = Nil Then Return

Declare Function GetTabBar Lib "UIKit" Selector "tabBar" (obj As Ptr) As Ptr
Var tabBar As Ptr = GetTabBar(tabController)

Var colorPtr As Ptr = ColorGroupToUIColor(value)

Declare Function BarAppearance Lib "UIKit" Selector "standardAppearance" (obj As Ptr) As Ptr
Declare Sub SetAppearance Lib "UIKit" Selector "setStandardAppearance:" (obj As Ptr, value As Ptr)

Declare Function StackedLayout Lib "UIKit" Selector "stackedLayoutAppearance" (obj As Ptr) As Ptr
Declare Function InlineLayout Lib "UIKit" Selector "compactInlineLayoutAppearance" (obj As Ptr) As Ptr
Declare Function NormalState Lib "UIKit" Selector "normal" (obj As Ptr) As Ptr

Var appearance As Ptr = BarAppearance(tabBar)
Var stackLayout As Ptr = StackedLayout(appearance)
Var inLayout As Ptr = InlineLayout(appearance)

Var normalState As Ptr = normalState(stackLayout)
Var normalInlineState As Ptr = NormalState(inLayout)

Declare Function NSClassFromString Lib "Foundation" (name As CFStringRef) As Ptr
Declare Function DictionaryWithObjectForKey Lib "UIKit" Selector "dictionaryWithObject:forKey:" (obj As Ptr, value As Ptr, key As CFStringRef) As Ptr

Var dict As Ptr = DictionaryWithObjectForKey( NSClassFromString("NSMutableDictionary") , colorPtr, "NSColor")

Declare Sub SetTextAttributes Lib "UIKit" Selector "setTitleTextAttributes:" (obj As Ptr, value As Ptr)

SetTextAttributes(normalState, dict)
SetTextAttributes(normalInlineState, dict)
SetAppearance(tabBar, appearance)

If System.Version.MajorVersion >= 15 Then
  Declare Sub SetScrollEdgeAppearance Lib "UIKit" Selector "setScrollEdgeAppearance:" (obj As Ptr, value As Ptr)
  SetScrollEdgeAppearance(tabBar, appearance)
End If</code></pre>



<h3 class="wp-block-heading">Testing the TabBar Color</h3>



<p>Add a new screen to the project so that our example app includes at least two screens. You can do this by selecting Insert &gt; Screen from the IDE toolbar.</p>



<p>To test the new methods, we need the app to use a <code>TabBar</code>. To enable that, select the iPhoneLayout item in the Navigator. Then, in the Inspector Panel, locate the Content label and choose Tabs from the associated popup menu. Finally, set <code>Screen1</code> as the content for Tab 0 using the &#8220;Tab 0 Content&#8221; popup menu.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" width="1860" height="1292" src="https://blog.xojo.com/wp-content/uploads/2025/07/SettingTab0.png" alt="" class="wp-image-15197" srcset="https://blog.xojo.com/wp-content/uploads/2025/07/SettingTab0.png 1860w, https://blog.xojo.com/wp-content/uploads/2025/07/SettingTab0-300x208.png 300w, https://blog.xojo.com/wp-content/uploads/2025/07/SettingTab0-1024x711.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/07/SettingTab0-768x533.png 768w, https://blog.xojo.com/wp-content/uploads/2025/07/SettingTab0-1536x1067.png 1536w" sizes="(max-width: 1860px) 100vw, 1860px" /></figure>
</div>


<p>Next, with <code>Screen1</code> still selected in the Navigator, click on the &#8220;Tab 1&#8221; label in the Layout Editor. Then, in the Inspector<strong> </strong>Panel, use the popup menu next to the &#8220;Tab 1 Content&#8221; label to select <code>Screen2</code>.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="1890" height="1262" src="https://blog.xojo.com/wp-content/uploads/2025/07/settingTab1.png" alt="" class="wp-image-15198" srcset="https://blog.xojo.com/wp-content/uploads/2025/07/settingTab1.png 1890w, https://blog.xojo.com/wp-content/uploads/2025/07/settingTab1-300x200.png 300w, https://blog.xojo.com/wp-content/uploads/2025/07/settingTab1-1024x684.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/07/settingTab1-768x513.png 768w, https://blog.xojo.com/wp-content/uploads/2025/07/settingTab1-1536x1026.png 1536w" sizes="auto, (max-width: 1890px) 100vw, 1890px" /></figure>
</div>


<p>With <code>Screen1</code> still selected in the Navigator, add a new property to it using the following values:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> <code>MyTabBarUnselectedTextColor</code></li>



<li><strong>Type:</strong> <code>ColorGroup</code></li>



<li><strong>Scope:</strong> Protected</li>
</ul>



<p>Now select the <code>Screen1.Opening</code> event handler and add this line of code:</p>



<pre class="wp-block-code"><code>MyTabBarUnselectedTextColor = New ColorGroup(Color.White, Color.LightGray)</code></pre>



<p>As the last step, select the <code>Screen1.AppearanceChanged</code> event handler and add this line of code:</p>



<pre class="wp-block-code"><code>Me.ParentTabBar.TabBarBackgroundColor = mNavigationBarColor
Me.ParentTabBar.TabBarTextColor = MyNavigationBarTextColor
Me.ParentTabBar.TabBarUnselectedTextColor = MyTabBarUnselectedTextColor</code></pre>



<p>All set! Now it’s time to run the example project in the Simulator or on your iPhone. You’ll see that the <code>TabBar</code> background color matches the one set for the <code>NavigationBar</code>, and the selected tab text color is consistent as well. The unselected tab text appears white in Light Mode and light gray in Dark Mode, reflecting the <code>ColorGroup</code> settings.</p>



<figure class="wp-block-video"><video controls src="https://blog.xojo.com/wp-content/uploads/2025/07/NavigationAndTabBar.mp4"></video></figure>



<p>As we’ve seen, Declares are a powerful way to tap into native iOS framework functions and routines. The most challenging part is often figuring out which ones to use since that requires digging into Apple’s developer documentation.</p>



<p>Download the example project from <a href="https://drive.google.com/file/d/1dN6mIe55FkUPEUl-_fanCMvXX3fdarr1/view?usp=sharing">this link</a>.</p>



<p>Happy Xojo coding!</p>



<p><em>Javier Menendez is an engineer at Xojo and has been using Xojo since 1998. He lives in Castellón</em>, <em>Spain and hosts regular Xojo hangouts en español. Ask Javier questions on Twitter at <a href="https://twitter.com/xojoes" target="_blank" rel="noreferrer noopener">@XojoES</a> or on the <a href="https://forum.xojo.com/u/javier_menendez/summary" target="_blank" rel="noreferrer noopener">Xojo Forum</a>.</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>



<p></p>
]]></content:encoded>
					
		
		<enclosure url="https://blog.xojo.com/wp-content/uploads/2025/07/NavigationAndTabBar.mp4" length="145232" type="video/mp4" />

			</item>
	</channel>
</rss>
