UIKit.UIFontDescriptor Class
Describes properties of a font, use to create fonts with certain features. Provides ways of finding fonts matching a description as well.

See Also: UIFontDescriptor Members

Syntax

[Foundation.Register("UIFontDescriptor", true)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_7_0)]
public class UIFontDescriptor : Foundation.NSObject, Foundation.INSCoding, Foundation.INSCopying, IDisposable

Remarks

Developers create UIFontDescriptors with a set of parameters they are interested in (font faces, font families, font attributes, fallbacks). You can consider these descriptors queries, which you can later use to create a concrete UIFont wit by using the UIFont.FromDescriptor method.

These objects are immutable, once created, they can not be changed. But given a UIFontDescriptor, you can create a more precise font descriptor instance with new information. You can create a new UIFontDescriptor with more detailed font attributes using the UIFontDescriptor.CreateWithAttributes method, extend one by explicitly setting a font face or font family using the UIFontDescriptor.CreateWithFace and UIFontDescriptor.CreateWithFamily methods, specify a desired font size or a transformation matrix with the UIFontDescriptor.CreateWithSize and UIFontDescriptor.CreateWithMatrix methods, or request that certain stylistic traits be present with UIFontDescriptor.CreateWithTraits.

This class exposes various static properties that return the UIFontDescriptor that matches the user's global preferences (font sizes) as well as the system font. These properties are: UIFontDescriptor.PreferredHeadline, UIFontDescriptor.PreferredBody, UIFontDescriptor.PreferredSubheadline, UIFontDescriptor.PreferredFootnote, UIFontDescriptor.PreferredCaption1 and UIFontDescriptor.PreferredCaption2.

You can use the UIFontDescriptor.GetMatchingFontDescriptors method to get a set of UIFontDescriptors that match your font explicitly, or you can use UIFontDescriptor.CreateWithTraits and UIKit.UIFont.FromDescriptor methods to match implicitly.

The following example shows how to create two fonts: one with the preferred font for body text, and then a bold version of the same font:

C# Example


// Creates a UIFont for the body text
var bodyDescriptor = UIFontDescriptor.PreferredBody;
UIFont bodyFont = UIFont.FromDescriptor (bodyDescriptor, 0);
	  
// Creates a bold version of it:
var boldDescriptor = bodyDescriptor.CreateWithTraits (UIFontDescriptorSymbolicTraits.Bold);
UIFont boldBodyFont = UIFont.FromDescriptor (boldDescriptor, 0);

The members of this class can be used from a background thread.

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0