IOS Uilabe and Uifont Usage Summary

Source: Internet
Author: User
Tags italic font

Initializes a Uilabel object and initializes the size of the

UILabel * label = [[UILabel alloc]initwithframe: CGRectMake (+ )];

Set the displayed text

Label. text=@ "123";

A font-related class with font size default 17

@property(nonatomic, retain) uifont*font;

//You can set font style after 7.0//nsstring *const uifonttextstyleheadline; the style used for the title//nsstring *const uifonttextstylesubheadline; the style used for the subtitle//nsstring *const uifonttextstylebody; the font used for the body//nsstring *const uifonttextstylefootnote; the font used for footnotes//nsstring *const UIFontTextStyleCaption1; for standard subtitle fonts//nsstring *const UIFontTextStyleCaption2; used to replace a caption fontLabel.font=[Uifont Preferredfontfortextstyle:uifonttextstylecaption2];//to tell you the truth, I don't see much difference.//set font and font size+ (Uifont *) Fontwithname: (NSString *) fontname Size: (cgfloat) fontSize;//returns an array of font family names for all fonts+ (Nsarray *) Familynames;//returns an array of font names by font family name+ (Nsarray *) Fontnamesforfamilyname: (NSString *) familyname;//set Normal font size+ (Uifont *) Systemfontofsize: (cgfloat) fontSize;//set Bold font font size+ (Uifont *) Boldsystemfontofsize: (cgfloat) fontSize;//Set Italic font size+ (Uifont *) Italicsystemfontofsize: (cgfloat) fontSize; //some read-only properties//Font family name@property (Nonatomic,ReadOnly, retain) NSString *familyname;//Font name@property (Nonatomic,ReadOnly, retain) NSString *FontName;//Font Size@property (Nonatomic,ReadOnly) cgfloat pointsize;//a font design model that represents the offset margin from the highest point@property (Nonatomic,ReadOnly) CGFloat Ascender;//model offset at bottom@property (Nonatomic,ReadOnly) cgfloat descender;//header height information for font models@property (Nonatomic,ReadOnly) cgfloat capheight;//xheight information for font models@property (Nonatomic,ReadOnly) cgfloat xheight;//Font Line Height@property (Nonatomic,ReadOnly) cgfloat lineheight Ns_available_ios (4_0);//Model Body Information@property (Nonatomic,ReadOnly) cgfloat leading;//creates a new font that is the same as the current font, except for the specified size-(Uifont *) Fontwithsize: (cgfloat) fontSize;//available after font 7.0 is returned by descriptive information+ (Uifont *) Fontwithdescriptor: (Uifontdescriptor *) Descriptor Size: (cgfloat) pointsize Ns_available_ios (7_0);//returns a description of the font, available after 7.0-(Uifontdescriptor *) FontDescriptor Ns_available_ios (7_0);

Set Font Color

Label. textcolor=[uicolor redcolor];

Set the shadow offset

Label. shadowoffset=cgsizemake ( 20);

Set Shadow Color

Label.shadowcolor=[uicolor blackcolor];

Setting the Alignment mode

Label. textalignment=nstextalignmentjustified;

enum {   //Align align to left edgeNstextalignmentleft =0,   //Center AlignmentNstextalignmentcenter =1,   //Align Right edgeNstextalignmentright =2,   //the last line is naturally alignedNstextalignmentjustified =3,   //Default AlignmentNstextalignmentnatural =4,
};typedef Nsinteger nstextalignment;

Multi-line text settings

Label. linebreakmode=nslinebreakbycharwrapping;

enum {   //Text Edge processingNslinebreakbywordwrapping =0,   //handle inappropriate characters in advancenslinebreakbycharwrapping,//Simple linear processingnslinebreakbyclipping,//The missing opening is denoted by an ellipsisNslinebreakbytruncatinghead,//The missing text shows an ellipsis at the endNslinebreakbytruncatingtail,//missing text displays ellipses in the middleNslinebreakbytruncatingmiddle
};typedef Nsuinteger Nslinebreakmode

Drawing with Attributedtext

@property (nonatomic,copy) nsattributedstring *attributedtext

Set the font color for highlighting

Label.highlightedtextcolor=[uicolor bluecolor];

Set whether to highlight

Label. highlighted=YES;

User interaction is turned off by default

label.userinteractionenabled=NO;

Valid, default is yes, invalid is gray

Label. enabled=NO;

Number of rows displayed, 0 for Infinity

@property(nonatomic) nsinteger numberoflines;

Width Adaptive size default is no

@property (nonatomic) BOOL adjustsfontsizetofitwidth;

Character adaptation width: deprecated

@property (nonatomic) BOOL adjustsletterspacingtofitwidth

Minimum adaptation size 2.0-6.0

@property (nonatomic) cgfloat minimumfontsize

After the minimum fit size of 6.0

@property (nonatomic) cgfloat minimumscalefactor

Adjustment in the vertical direction

@property(nonatomic) uibaselineadjustment baselineadjustment;

enum {   // adjust text corresponding to baseline position    uibaselineadjustmentalignbaselines   ,// adjusts the center of text relative to its border    uibaselineadjustmentaligncenters,   // adjusts the text relative to the upper-left corner of the border by default   Uibaselineadjustmentnone,
} uibaselineadjustment;

Return text Draw Rectangle

-(CGRect) Textrectforbounds: (cgrect) bounds Limitedtonumberoflines: (nsinteger) numberoflines;

Text Drawing functions

-(void) Drawtextinrect: (cgrect) rect

Text Auto Layout parameters

@property (nonatomic) cgfloat preferredmaxlayoutwidth

IOS Uilabe and Uifont Usage Summary

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.