IOS UIFont font Daquan

Source: Internet
Author: User

We often need to set UIlabel, UIbutton, and UItextfield fonts during development. UIFont is used at this time. The following describes the usage of UIFont for reference only.

 


UIFont is used to obtain and set font information. This class provides the attributes and font information of the fonts used for output. We can pass its object into the function like a parameter.


Generally, we do not need to use the alloc or int method to initialize the UIFont object. Most of the time we use UIFont, we use its class method. These methods will set the object attributes and return a font object.

 


For example:


_ CenterLabel = [[UILabel alloc] initWithFrame: CGRectMake (115, 12, 85, 21)];

_ CenterLabel. text = @ "dealer query ";

[_ CenterLabel setFont: [UIFont fontWithName: @ "Helvetica" size: 17.0];

[Self. view addSubview: _ centerLabel];


The following two functions create fonts:

+ FontWithName :( NSString *) fontName size :( CGFloat) fontSize is created and a font object with the specified font type and size is returned. fontName specifies the name and style of the font set (such as, fontsize specifies the fontsize.

-FontWithSize: returns the font size.

As mentioned above, we need to set the font set. The fonts we use in IOS include:

Font Family: American Typewriter (AmericanTypewriter, AmericanTypewriter-Bold)
Font Family: AppleGothic (AppleGothic)
Font Family: Arial (ArialMT, Arial-BoldMT, Arial-BoldItalicMT, Arial-ItalicMT)
Font Family: Arial Rounded MT Bold (ArialRoundedMTBold)
Font Family: Arial Unicode MS (ArialUnicodeMS)
Font Family: Courier (Courier, Courier-BoldOblique, Courier-Oblique, Courier-Bold)
Font Family: Courier New (CourierNewPS-BoldMT, CourierNewPS-ItalicMT, CourierNewPS-BoldItalicMT, CourierNewPSMT)
Font Family: db LCD Temp (DBLCDTempBlack)
Font Family: Georgia (Georgia-Bold, Georgia, Georgia-BoldItalic, Georgia-Italic)
Font Family: Helvetica (Helvetica-Oblique, Helvetica-BoldOblique, Helvetica, Helvetica-Bold) default Font
Font Family: Helvetica Neue (HelveticaNeue, HelveticaNeue-Bold)
Font Family: Hiragino Kaku Gothic *** W3 (HiraKakuProN-W3)
Font Family: Hiragino Kaku Gothic *** W6 (HiraKakuProN-W6)
Font Family: Marker Felt (MarkerFelt-Thin)
Font Family: STHeiti J (STHeitiJ-Medium, STHeitiJ-Light)
Font Family: STHeiti K (STHeitiK-Medium, STHeitiK-Light)
Font Family: STHeiti SC (STHeitiSC-Medium, STHeitiSC-Light)
Font Family: STHeiti TC (STHeitiTC-Light, STHeitiTC-Medium)
Font Family: Times New Roman (TimesNewRomanPSMT, TimesNewRomanPS-BoldMT, TimesNewRomanPS-BoldItalicMT, TimesNewRomanPS-ItalicMT)
Font Family: Trebuchet MS (TrebuchetMS-Italic, TrebuchetMS, Trebuchet-BoldItalic, TrebuchetMS-Bold)
Font Family: Verdana (Verdana-Bold, Verdana-BoldItalic, Verdana, Verdana-Italic)
Font Family: Zapfino (Zapfino)


+ (UIFont *) systemFontOfSize :( CGFloat) fontSize: use the standard interface to return the font objects of the specified size.
+ (CGFloat) systemFontSize returns the standard system font size.

+ (UIFont *) boldSystemFontOfSize :( CGFloat) fontSize: The returned font object uses the standard interface to specify the font size and append the simhei style.

+ (CGFloat) buttonFontSize the return button uses a standard font.

+ (NSArray *) familyNames returns an array of available system font set names. An NSString array object. Each element contains the font set name. The name of the font set is equivalent to the base name of the font. For example, Times New Roman. You can enter the returned string to the fontNamesForFamilyName: method to obtain the name of the available font set. Then you can use these appropriate names to retrieve the font objects.


+ (NSArray *) fontNamesForFamilyName :( NSString *) familyName) Name of the familyName font set. Use the familyNames method to obtain the name of a font set in the system.


UIFont fontWithName does not know the font name. I have read all the solutions below!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.