Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The string constants defined at
let UIFontTextStyleTitle1: String
let UIFontTextStyleTitle2: String
let UIFontTextStyleTitle3: String
let UIFontTextStyleHeadline: String
let UIFontTextStyleSubheadline: String
let UIFontTextStyleBody: String
let UIFontTextStyleFootnote: String
let UIFontTextStyleCaption1: String
let UIFontTextStyleCaption2: String
let UIFontTextStyleCallout: String
Are required for UIFont.GetPreferredFontForTextStyle
Looking at https://github.com/xamarin/xamarin-macios/blob/master/src/uikit.cs#L4858 I've noticed we do have the constants yet they are internal. I've contacted the bindings author to confirm the reason and will update the code accordingly.
Use the UIFont properties for those names instead, you do not need to call a method that takes an NSString whose value is not discoverable:
On the UIFont class, use one of these properties:
This information is even documented on the UIFont documentation:
The docs talk about iOS 7 features, some new properties were added in 9.0, which are not listed in the documentation, we should update that.
That works if the dev can hard-code the style (UIFont.PreferredHeadline) but does not work if the style is variable (PreferredFontForTextStyle). The source code we show is incorrect:
headlineLabel.Font = UIFont.PreferredFontForTextStyle(UIFontTextStyle.Headline);
bodyText.Font = UIFont.PreferredFontForTextStyle(UIFontTextStyle.Body);
But we don't *have* UIFontTextStyle.Headline or .Body (we don't have UIFontTextStyle).
I think the original issue was misunderstood, the mentioned API requires the NSString constant. However we can expose something better (and enum) in our public API.
PR merged: https://github.com/xamarin/xamarin-macios/commit/96f0c092259a332a053b1e7dbd68f5ebe017acc4