![]() NET MAUI and Xamarin.Formsĭuotone Icons are special icons that can have two different colors. Once that is in place, we can use this font just like we did in Xamarin.Forms: Using Font Awesome Duotone icons in. ![]() Instead of fiddling in some obscure AssemblyInfo.cs file and using some magic attributes, we can just open our MauiProgram.cs file and add our font via the ConfigureFonts methond of the MauiAppBuilder class: public static MauiApp CreateMauiApp()įonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular") įonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold") įonts.AddFont("Font Awesome 6 Pro-Regular-400.otf", "FontAwesome") ![]() As with forms, you need to add the otf file to you project and set the Build Action to ‘Embedded Resource’. NET MAUI is almost identical to using it in Xamarin.Forms. The only thing we have to do is setting the FontFamily of a label to whatever Alias we’ve defined in the ExportFont attribute and set the Text value of the label to the name of the icon you want to show on the screen: Īnd just like that, you have an awesome icon in your app: With the Alias property, we can define a short-hand notation that we can use in code to refer to this font.Īs soon as all of this is in place, we can start using this font. The first parameter of this ExportFont attribute is the fontFileName and refers to the font file we want to use (make sure the spelling is exact!). Next, we need to open the AssemblyInfo.cs file and add the following line of code: Set the file’s Build Action to ‘Embedded Resource’: To use Font Awesome in your Xamarin Forms project, download the Font Awesome font file (otf) and add it to your project: Let me show you how! Using Font Awesome icons in Xamarin.Forms You can even use the ‘Duotone’ icons which have 2 colors and which look extra nice and can give some depth to your icons (when using nicer colors then I use in this example □ ). ![]() It’s a huge library and it’s super easy to use in. In almost all of my mobile apps, I use Font Awesome to display icons. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |