1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// GMLabel.h
// Gengmei
//
// Created by Thierry on 12/26/14.
// Copyright (c) 2014 Wanmeichuangyi. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface GMLabel : UILabel
typedef NS_ENUM(NSInteger, GMLabelVerticalAlignment){
GMLabelVerticalAlignmentTop = 0, // 垂直方向顶部对齐
GMLabelVerticalAlignmentMiddle, // 垂直方向中间对齐
GMLabelVerticalAlignmentBottom, // 垂直方向底部对齐
};
/**
* @brief 垂直方向对齐。默认是 GMLabelVerticalAlignmentMiddle。因为有这个属性,所以需要重写 drawTextInRect
*/
@property (nonatomic,assign) GMLabelVerticalAlignment verticalAlignment;
/**
* @brief 文字与label边框的padding。因为有这个方法,所以重写了 intrinsicContentSize
*/
@property (nonatomic, assign) UIEdgeInsets paddingEdge;
/**
* @author licong, 16-12-30 17:12:50
*
* 创建一个UILabel
*
* @param color 色值
* @param fontSize font大小
*
* @return 一个新的UILabel
*
* @since 5.8
*/
+ (GMLabel *)labelWithTextColor:(UIColor *)color fontSize:(CGFloat)fontSize;
/**
* @brief 创建一个UILabel
*
* @param textAlignment 对齐方式
* @param backgroundColor 背景颜色
* @param textColor 文字颜色
* @param fontSize 字号
*/
+ (GMLabel *)labelWithTextAlignment:(NSTextAlignment)textAlignment backgroundColor:(UIColor*)backgroundColor textColor:(UIColor*)textColor fontSize:(CGFloat )fontSize;
/**
* @brief 设置label属性
*
* @param textAlignment 对齐方式
* @param backgroundColor 背景颜色
* @param textColor 文字颜色
* @param fontSize 字号
*/
- (void)setTextAlignment:(NSTextAlignment)textAlignment backgroundColor:(UIColor*)backgroundColor textColor:(UIColor*)textColor fontSize:(CGFloat )fontSize;
@end
NS_ASSUME_NONNULL_END