2013年3月13日 星期三

NSLineBreakMode and NSTextAlignment 對齊與換行

typedef NS_ENUM(NSInteger, NSLineBreakMode) {
    NSLineBreakByWordWrapping = 0,  /* Wrap at word boundaries, default */
    NSLineBreakByCharWrapping,      /* Wrap at character boundaries */
    NSLineBreakByClipping,          /* Simply clip */
    NSLineBreakByTruncatingHead,    /* Truncate at head of line: "...wxyz" */
    NSLineBreakByTruncatingTail,    /* Truncate at tail of line: "abcd..." */
    NSLineBreakByTruncatingMiddle   /* Truncate middle of line:  "ab...yz" */
} NS_ENUM_AVAILABLE_IOS(6_0);
NSLineBreakByWordWrapping 以word為單位換行, 以word為單位截斷
NSLineBreakByCharWrapping 以letter為單位換行, 以letter為單位截斷
NSLineBreakByClipping 以word為單位換行, 以letter為單位截斷
最後三個看英文註解內容


typedef NS_ENUM(NSInteger, NSTextAlignment) {
    NSTextAlignmentLeft      = 0,    // Visually left aligned
    NSTextAlignmentCenter    = 1,    // Visually centered
    NSTextAlignmentRight     = 2,    // Visually right aligned
    NSTextAlignmentJustified = 3,    // Fully-justified. The last line in a paragraph is natural-aligned.
    NSTextAlignmentNatural   = 4,    // Indicates the default alignment for script
} NS_ENUM_AVAILABLE_IOS(6_0);
前三個分別為靠左, 置中, 靠右對齊
NSTextAlignmentJustified, NSTextAlignmentNatural不適用在UILabel

沒有留言:

張貼留言