NNLabel
macOS NSView custom,类似于 UILabel
示例
要运行示例项目,请克隆仓库,然后从 Example 目录运行 pod install
typedef NS_ENUM(NSInteger, NSContentVerticalAlignment) {
NSContentVerticalAlignmentTop = 0,
NSContentVerticalAlignmentCenter = 1,
NSContentVerticalAlignmentBottom = 2,
};
@interface NNLabel : NSView
@property(nullable, nonatomic,copy) NSString *text; // default is nil
@property(nonatomic, strong) NSFont *font; // default is nil (system font 17 plain)
@property(nonatomic, strong) NSColor *textColor; // default is labelColor
@property(nonatomic, assign) NSTextAlignment textAlignment; // default is NSTextAlignmentLeft
/// 整体内容垂直对齐方向
@property(nonatomic, assign) NSContentVerticalAlignment contentVerticalAlignment; // default is NSContentVerticalAlignmentTop
@property(nonatomic, assign) NSLineBreakMode lineBreakMode; // default is NSLineBreakByTruncatingTail. used for single and multiple lines of text
// the underlying attributed string drawn by the label, if set, the label ignores the properties above.
@property(nullable, nonatomic,copy) NSAttributedString *attributedText; // default is nil
// the 'highlight' property is used by subclasses for such things as pressed states. it's useful to make it part of the base class as a user property
@property(nullable, nonatomic,strong) NSColor *highlightedTextColor; // default is nil
@property(nonatomic,getter=isHighlighted) BOOL highlighted; // default is NO
@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default is NO
@property(nonatomic,getter=isEnabled) BOOL enabled; // default is YES. changes how the label is drawn
@property(nonatomic, copy) void(^mouseDownBlock)(NNLabel *sender);
///返回事件
- (void)actionBlock:(void(^)(NNLabel *sender))block;
要求
osx: 10.12
安装
NNLabel 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'NNLabel'
作者
shang1219178163,[电子邮箱地址显示为保护形式]
授权
NNLabel可在MIT授权下使用。更多信息请参阅LICENSE文件。