public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); customizedTab = new CurvedBottomNavigationView(); element = Element as CurvedBottomTabbedPage; customizedTab.Frame = this.TabBar.Frame; customizedTab.Items = this.TabBar.Items; customizedTab.SelectedItem = this.TabBar.SelectedItem; customizedTab.TintColor = this.TabBar.TintColor; customizedTab.UnselectedItemTintColor = this.TabBar.UnselectedItemTintColor; customizedTab.BarBackgroundColor = this.TabBar.BarTintColor; customizedTab.BackgroundColor = Xamarin.Forms.Color.Transparent.ToUIColor(); customizedTab.ItemSpacing = 4f; customizedTab.ClipsToBounds = true; this.TabBar.RemoveFromSuperview(); SetMenuItems(); // Creates a Button var appButton = new UIButton(UIButtonType.Custom); UIImage imageAppButtonButton = UIImage.FromBundle(element.FabIcon); if (imageAppButtonButton != null) { appButton.SetImage(imageAppButtonButton, UIControlState.Normal); } // Sets width and height to the Button appButton.Frame = new CGRect(0.0f, 0.0f, 48, 48); //appButton.SetBackgroundImage(imageAppButtonButton, UIControlState.Normal); appButton.BackgroundColor = UIColor.FromCGColor(element.FabBackgroundColor.ToCGColor()); CGPoint centers = TabBar.Center; centers.Y = this.customizedTab.Frame.Y; appButton.Center = centers; var eventHandler = new EventHandler(ButtonClick); appButton.AddTarget(eventHandler, events: UIControlEvent.TouchUpInside); //Create shadow effect appButton.Layer.ShadowColor = UIColor.Black.CGColor; appButton.Layer.ShadowOffset = new CGSize(width: 0.0, height: 5.0); appButton.Layer.ShadowOpacity = 0.5f; appButton.Layer.ShadowRadius = 2.0f; appButton.Layer.MasksToBounds = false; appButton.Layer.CornerRadius = 24; // Adds the Button to the view View.Add(customizedTab); View.AddSubview(appButton); }
protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e) { base.OnElementChanged(e); try { element = Element as CurvedBottomTabbedPage; var metrics = Resources.DisplayMetrics; var width = metrics.WidthPixels; var height = metrics.HeightPixels; if (!(GetChildAt(0) is ViewGroup layout)) { return; } if (!(layout.GetChildAt(1) is BottomNavigationView bottomNavigationView)) { return; } bottomNavigationView.RemoveFromParent(); bottomNavigationView.RemoveAllViews(); bottomNavigationView.RemoveAllViewsInLayout(); var bottomView = LayoutInflater.From(Context).Inflate(Resource.Layout.BottomNavBar, null); bottombar = bottomView.FindViewById <CurvedBottomNavigationView>(Resource.Id.bottom_nav_bar); bottombar.RemoveFromParent(); actionbutton = bottomView.FindViewById <FloatingActionButton>(Resource.Id.fab); actionbutton.RemoveFromParent(); SetTabItems(); SettingUpMenu(); OnChildrenCollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); SetFabProperties(); actionbutton.Click += Actionbutton_Click; bottombar.LabelVisibilityMode = LabelVisibilityMode.LabelVisibilityLabeled; layout.AddView(actionbutton); layout.AddView(bottombar); bottombar.SetZ(0); UpdateBarBackgroundColor(); UpdateBarTextColor(); UpdateItemIconColor(); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void CreatingTabBar() { element = Element as CurvedBottomTabbedPage; this.RemoveFromParentViewController(); if (customizedTab != null) { this.customizedTab.RemoveFromSuperview(); View.WillRemoveSubview(this.customizedTab); } if (appButton != null) { this.appButton.RemoveFromSuperview(); View.WillRemoveSubview(this.appButton); } this.TabBar.RemoveFromSuperview(); View.WillRemoveSubview(this.TabBar); customizedTab.Frame = this.TabBar.Frame; customizedTab.Items = this.TabBar.Items; customizedTab.SelectedItem = this.TabBar.SelectedItem; customizedTab.TintColor = this.TabBar.TintColor; customizedTab.UnselectedItemTintColor = this.TabBar.UnselectedItemTintColor; customizedTab.BarBackgroundColor = this.TabBar.BarTintColor; customizedTab.BackgroundColor = Xamarin.Forms.Color.Transparent.ToUIColor(); customizedTab.ItemSpacing = 4f; customizedTab.ClipsToBounds = true; // Creates a Button appButton = new UIButton(UIButtonType.Custom); UIImage imageAppButtonButton = UIImage.FromBundle(element.FabIcon); if (imageAppButtonButton != null) { appButton.SetImage(imageAppButtonButton, UIControlState.Normal); } // Sets width and height to the Button appButton.Frame = new CGRect(0.0f, 0.0f, 48, 48); //appButton.SetBackgroundImage(imageAppButtonButton, UIControlState.Normal); appButton.BackgroundColor = UIColor.FromCGColor(element.FabBackgroundColor.ToCGColor()); CGPoint centers = TabBar.Center; centers.Y = this.customizedTab.Frame.Y; appButton.Center = centers; var eventHandler = new EventHandler(ButtonClick); appButton.AddTarget(eventHandler, events: UIControlEvent.TouchUpInside); //Create shadow effect appButton.Layer.ShadowColor = UIColor.Black.CGColor; appButton.Layer.ShadowOffset = new CGSize(width: 0.0, height: 5.0); appButton.Layer.ShadowOpacity = 0.5f; appButton.Layer.ShadowRadius = 2.0f; appButton.Layer.MasksToBounds = false; appButton.Layer.CornerRadius = 24; if (Device.Idiom == TargetIdiom.Phone) { SetMenuItemsForPhone(); } else { SetMenuItemsForTablet(); } //Adds the Button to the view if (View.Subviews.Length == 1) { View.Add(customizedTab); View.Add(appButton); } }