FontAwesome Pro and xamarin.ios only one font can be active

后端 未结 3 2033
不知归路
不知归路 2020-12-10 15:56

So I have been looking for an answer to this.

I can\'t get all 3 fonts in FontAwesome Pro to work with my xamarin native (iOS) to work.

I do use

         


        
3条回答
  •  时光取名叫无心
    2020-12-10 16:16

    To use Font Awesome 5 Pro in Xamarin.Forms

    Use it like below... (Thanks to the helpful code of SushiHangover) * Font Awesome 5 Brands *-- FontAwesome5BrandsRegular * Font Awesome 5 Pro *-- FontAwesome5ProLight *-- FontAwesome5ProRegular *-- FontAwesome5ProSolid

    App.Xaml.cs

            Current.Resources = new ResourceDictionary();
            // Font awesome
            Current.Resources["FontawesomeSolid"] = Device.RuntimePlatform == Device.iOS ? "Font Awesome 5 Pro" : "fa-solid-900.ttf#Font Awesome 5 Pro";
            Current.Resources["FontawesomeRegular"] = Device.RuntimePlatform == Device.iOS ? "FontAwesome5Regular" : "fa-regular-400.ttf#Font Awesome 5 Pro";
            Current.Resources["FontawesomeLight"] = Device.RuntimePlatform == Device.iOS ? "FontAwesome5ProLight" : "fa-light-300.ttf#Font Awesome 5 Pro";
            Current.Resources["FontawesomeBrands"] = Device.RuntimePlatform == Device.iOS ? "FontAwesome5ProBrands" : "fa-brands-400.ttf#fFont Awesome 5 Pro";
    
    
            Current.Resources.Add("ShareIconLabel", new Style(typeof(Label))
            {
                Setters =
                {
                    new Setter { Property = Label.TextColorProperty, Value = Color.White},
                    new Setter { Property = View.HorizontalOptionsProperty, Value = LayoutOptions.End},
                    new Setter { Property = View.VerticalOptionsProperty, Value = LayoutOptions.Center},
                    new Setter { Property = AbsoluteLayout.LayoutBoundsProperty, Value = new Rectangle (0.90, 0.5, 0.2, 1)},
                    new Setter { Property = AbsoluteLayout.LayoutFlagsProperty, Value = AbsoluteLayoutFlags.All},
                    new Setter { Property = Label.FontSizeProperty, Value = 30},
                    new Setter { Property = Label.FontFamilyProperty, Value = Current.Resources["FontawesomeLight"] },
                    new Setter { Property = Label.TextProperty, Value = "\uf1e0" } // Share Icon
                }
            });
    

    MySharePage.Xaml

            
                
            
    

提交回复
热议问题