dewango / BottomNavigationBarXF

Bottom Navigation Bar for Xamarin Forms
MIT License
187 stars 97 forks source link

Not working On iOS #103

Open tahirmehraj opened 6 years ago

tahirmehraj commented 6 years ago

Hi , this is not working on iOS . I can't see the tab colour and the icon badges. Attaching the screenshot below . Please help me Out screen shot 2018-05-10 at 7 20 59 pm

tahirmehraj commented 6 years ago

@here Anyone looking into this ?

shivanimangla13 commented 6 years ago

Here tab colour will set according to the background colour of the tabbar. Try to set another background color like "black" then see the result tab colour will change automatically.

And badges are also working in this,

Please see below:

Add custom renderer in iOS like this:

" using System; using BottomBar.XamarinForms; using Xamarin.Forms; using Xamarin.Forms.Platform.iOS; using SchoolApp.iOS; using System.ComponentModel;

[assembly: ExportRenderer(typeof(BottomBarPage), typeof(BottomBarPageRenderer))] namespace SchoolApp.iOS { class BottomBarPageRenderer : TabbedRenderer {

protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e);

if (e.NewElement != null)
{
    BottomBarPage bottomBarPage = e.NewElement as BottomBarPage;
    AddPropertyChangedHandlersForPages();
}

}

void AddPropertyChangedHandlersForPages() { BottomBarPage bottomBarPage = Element as BottomBarPage; foreach (var page in bottomBarPage.Children) { page.PropertyChanged += OnPagePropertyChanged; UpdateTabBadge(page); } } public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated);

BottomBarPage bottomBarPage = Element as BottomBarPage;
foreach (var page in bottomBarPage.Children)
{
    UpdateTabBadge(page);
}

}

void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == BottomBarPageExtensions.BadgeCountProperty.PropertyName) { UpdateTabBadge((Page)sender); } } private void UpdateTabBadge(Page page) { if (TabBar != null && TabBar.Items != null) { var badgeCount = BottomBarPageExtensions.GetBadgeCount(page); var tabIndex = Tabbed.Children.IndexOf(page); TabBar.Items[tabIndex].BadgeValue = (badgeCount == 0 ? null : badgeCount.ToString()); } } } }"

image