//
// NSText.h
// UIKit
//
// Copyright (c) 2011-2015 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#if __has_include(<CoreText/CTParagraphStyle.h>)
#import <CoreText/CTParagraphStyle.h>
#endif
#import <UIKit/UIKitDefines.h>
NS_ASSUME_NONNULL_BEGIN
/* Values for NSTextAlignment */
typedef NS_ENUM(NSInteger, NSTextAlignment) {
NSTextAlignmentLeft = 0, // Visually left aligned 左对其
#if TARGET_OS_IPHONE
NSTextAlignmentCenter = 1, // Visually centered 居中
NSTextAlignmentRight = 2, // Visually right aligned 右对其
#else /* !TARGET_OS_IPHONE */
NSTextAlignmentRight = 1, // Visually right aligned
NSTextAlignmentCenter = 2, // Visually centered
#endif
NSTextAlignmentJustified = 3, // Fully-justified. The last line in a paragraph is natural-aligned.
// 完全有道理。一个段落的最后一行是natural-aligned。
NSTextAlignmentNatural = 4, // Indicates the default alignment for script 显示脚本的默认对齐方式
} NS_ENUM_AVAILABLE_IOS(6_0);
#if __has_include(<CoreText/CTParagraphStyle.h>)
// 文本对其方式切换函数
// CTTextAlignment 和 NSTextAlignment 进行互换
UIKIT_EXTERN CTTextAlignment NSTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment) NS_AVAILABLE_IOS(6_0);
UIKIT_EXTERN NSTextAlignment NSTextAlignmentFromCTTextAlignment(CTTextAlignment ctTextAlignment) NS_AVAILABLE_IOS(6_0);
#endif
/* Values for NSWritingDirection */
// 写作方向
typedef NS_ENUM(NSInteger, NSWritingDirection) {
NSWritingDirectionNatural = -1, // Determines direction using the Unicode Bidi Algorithm rules P2 and P3 决定了方向使用Unicode Bidi算法规则P2和P3
NSWritingDirectionLeftToRight = 0, // Left to right writing direction 从左到右
NSWritingDirectionRightToLeft = 1 // Right to left writing direction 从右到左
} NS_ENUM_AVAILABLE_IOS(6_0);
NS_ASSUME_NONNULL_END
网友评论