Xamarin forms iOS apply same font but different style - ios

I have a xamarin forms app. I want to make use of Roboto Font Family, from Google Fonts. Actually, Roboto Light and Roboto Regular. What's the name for Roboto Light and Roboto Regular for iOS?
<OnPlatform x:Key="RobotoLightFontFamily" x:TypeArguments="x:String">
<On Platform="UWP" Value="/Assets/Fonts/Roboto-Light.ttf#Roboto" />
<On Platform="iOS" Value="Roboto Light" />
<On Platform="Android" Value="Roboto-Light.ttf#Roboto" />
</OnPlatform>
<OnPlatform x:Key="RobotoRegularFontFamily" x:TypeArguments="x:String">
<On Platform="UWP" Value="/Assets/Fonts/Roboto-Regular.ttf#Roboto" />
<On Platform="iOS" Value="Roboto" />
<On Platform="Android" Value="Roboto-Regular.ttf#Roboto" />
</OnPlatform>
It does not work like this... It only applies one font instead of both when using each font family foreach component

After some tries, naming it Roboto-Light works.

Related

Find path of local image of iOS project in Xamarin

I have an Image view like this:
<Image Source="{StaticResource AppIcon}" WidthRequest="80" HeightRequest="180" IsEnabled="True" ></Image>
Then i want to declare two different paths for either Android and iOS environment as:
<ResourceDictionary>
<OnPlatform x:TypeArguments="ImageSource" x:Key="AppIcon">
<On Platform="Android" Value="/Resources/drawable/splash_logo.png" />
<On Platform="iOS" Value="????" />
</OnPlatform>
</ResourceDictionary>
The problem is that i don't know how load my image from assets catalog in iOS project (android goes ok).
Can anyone help me?
if you are using native resources for Android and Asset Catalog for iOS then use only the name of file as source.
For example:
Files path in native projects:
Android - /resource/drawable-{size}/security.png
iOS - /Assets.xcassets/security.imageset/{name/size}.{png/pdf/json}
Using XAML:
<Image Source="security" />
Using C#:
Image.Source = "security";
(XAML) If the name of file is different for Android and iOS then use the OnPlatform + On tags but value will be still only the name without extension.
<On Platform="Android" Value="security" />
<On Platform="iOS" Value="devices" />
For C# you can use
if (Device.Platform == Device.Android)
Image.Source = "security";
else
Image.Source = "devices";

Xamarin IOS Shell Itemtemplate FlyoutIcon FontAwesome

I have an Xamarin Shell App. I pulled the code straight from MSDN for the Shell Itemtemplate and it works fine an Android but on IOS the FlyoutIcon is not appearing. I have a feeling it has to do with the fact that I am using FontAwesome for Icons. However I have yet to run across any documentation explaining why there would be an issue with IOS. The icons work perfectly everywehre else in the app. Below is the code for the shell item
<!-- ItemTemplate is for ShellItems as displayed in a Flyout-->
<Shell.ItemTemplate>
<DataTemplate>
<ContentView BackgroundColor="Transparent">
<Grid ColumnDefinitions="0.2*,0.8*" Margin="10">
<Image Source="{Binding FlyoutIcon}"
Margin="5"
HeightRequest="20" />
<Label Grid.Column="1"
Text="{Binding Title}"
TextColor="LightSlateGray"
FontAttributes="Bold"
VerticalTextAlignment="Center" />
</Grid>
</ContentView>
</DataTemplate>
</Shell.ItemTemplate>

Accessibility - voiceover not working in swipeviewitems within a bindablelayout - Xamarin.forms iOS

The UI and commands are working fine both in iOS and android. But the accessibility Voice over is not working in iOS.. Also the talkback is working fine for both the swipeitems in Android.
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem Text="Favorite"
IconImageSource="favorite.png"
BackgroundColor="LightGreen"
Command="{Binding Command1}" />
<SwipeItem Text="Delete"
IconImageSource="delete.png"
BackgroundColor="LightPink"
Command="{Binding Command2}"/>
</SwipeItems>
</SwipeView.RightItems>
<!-- Content -->
<Grid HeightRequest="60"
WidthRequest="300"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>

Xamarin.Forms custom font not picked up on iOS device when FontAttributes specified

I'm using a custom font in our app, and have found that if I set a FontAttributes="Bold" for a Label style using the font, it works on the iOS simulator, but not on a real device.
Steps taken:
1. Added the font Effra_Std_Reg.ttf to the resources folder.
2. Added this to the Fonts Provided By The Application element in Info.plist and set its build actions.
3. Created Styles in App.XAML.
4. Added these styles to the XAML on my page.
All the above works fine for a Label with no FontAttributes set. As soon as I set FontAttributes="Bold" on either the Style or the Label itself, the system font is used insted. Note that this works on the Simulator.
I know that the FontFamily is the font Name as defined inside the ttf file - not the ttf filename.
This on an iPad running iOS 10.3.3.
My App.XAML is:
<?xml version="1.0" encoding="utf-8" ?>
<Application x:Class="FontTest.App"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="FontSize" Value="30" />
</Style>
<Style x:Key="PlainLabelStyle" TargetType="Label">
<Setter Property="FontFamily">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
Android="Effra_Std_Rg.ttf#Effra"
iOS="Effra" />
</Setter.Value>
</Setter>
</Style>
<Style x:Key="BoldLabelStyle" TargetType="Label">
<Setter Property="FontFamily">
<Setter.Value>
<OnPlatform x:TypeArguments="x:String"
Android="Effra_Std_Bd.ttf#Effra"
iOS="Effra" />
</Setter.Value>
</Setter>
<Setter Property="FontAttributes" Value="Bold" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
And my page XAML (extract) is:
<Label Grid.Row="4"
Grid.Column="1"
Style="{StaticResource BoldLabelStyle}"
Text="QWERTYUIOPASDFGHJKLZXCVBNM" />
To get it working on the device, I had to include the bold font file (Effra_Std_Bd.ttf), and specify a FontFamily of 'Effra-Bold'.
So it appears that the FontFamily needs to be the Name and the Style.
Strange that it worked on the Simulator.

Cordova Tools for VS 2005: iOS app does not display splashscreen and icons

Using VS 2013 Cordova Tools (the current version), my iOS app does not display the given splashscreen and icons unless I set <icon> and <splashscreen> elements in config.xml. However, when config.xml is edited using the visual editor, it simply deletes all <icon> and <splashscreen> elements. Am I missing something?
Obs: icons and splash screen works for android apps out of the box, it just does not work for iOS.
Unfortunately this is a known issue when using the latest version of vs-mda-remote with VS 2013.
You should be able to add this XML to config.xml via Right-Click > View Code to resolve the issue.
<platformname="ios">
<iconsrc="res/icons/ios/icon-60-3x.png"width="180"height="180" />
<iconsrc="res/icons/ios/icon-60.png"width="60"height="60" />
<iconsrc="res/icons/ios/icon-60-2x.png"width="120"height="120" />
<iconsrc="res/icons/ios/icon-76.png"width="76"height="76" />
<iconsrc="res/icons/ios/icon-76-2x.png"width="152"height="152" />
<iconsrc="res/icons/ios/icon-40.png"width="40"height="40" />
<iconsrc="res/icons/ios/icon-40-2x.png"width="80"height="80" />
<iconsrc="res/icons/ios/icon-57.png"width="57"height="57" />
<iconsrc="res/icons/ios/icon-57-2x.png"width="114"height="114" />
<iconsrc="res/icons/ios/icon-72.png"width="72"height="72" />
<iconsrc="res/icons/ios/icon-72-2x.png"width="144"height="144" />
<iconsrc="res/icons/ios/icon-small.png"width="29"height="29" />
<iconsrc="res/icons/ios/icon-small-2x.png"width="58"height="58" />
<iconsrc="res/icons/ios/icon-50.png"width="50"height="50" />
<iconsrc="res/icons/ios/icon-50-2x.png"width="100"height="100" />
</platform>
<platformname="ios">
<splashsrc="res/screens/ios/screen-iphone-portrait.png"width="320"height="480" />
<splashsrc="res/screens/ios/screen-iphone-portrait-2x.png"width="640"height="960" />
<splashsrc="res/screens/ios/screen-ipad-portrait.png"width="768"height="1024" />
<splashsrc="res/screens/ios/screen-ipad-portrait-2x.png"width="1536"height="2048" />
<splashsrc="res/screens/ios/screen-ipad-landscape.png"width="1024"height="768" />
<splashsrc="res/screens/ios/screen-ipad-landscape-2x.png"width="2048"height="1536" />
<splashsrc="res/screens/ios/screen-iphone-568h-2x.png"width="640"height="1136" />
<splashsrc="res/screens/ios/screen-iphone-portrait-667h.png"width="750"height="1334" />
<splashsrc="res/screens/ios/screen-iphone-portrait-736h.png"width="1242"height="2208" />
<splashsrc="res/screens/ios/screen-iphone-landscape-736h.png"width="2208"height="1242" />
</platform>
More known issues: https://www.visualstudio.com/explore/cordova-known-issues-vs
I had similar problem. I simply didn't use graphical config editor and use only text one.
However, the Visual Studio 2015 RC fixes this problem and there is an implicit configuration for every icon and splash screen.

Resources