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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//
// GMButton.h
// Gengmei
//
// Created by Thierry on 12/26/14.
// Copyright (c) 2014 Wanmeichuangyi. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
//渐变按钮渐变方向
typedef NS_ENUM(NSUInteger, GMGradientType) {
GMGradientTypeTopToBottom = 0, //从上到小
GMGradientTypeLeftToRight = 1, //从左到右
GMGradientTypeLeftUpToRightLow = 2, //左上到右下
GMGradientTypeRightUpToLeftLow = 3, //右上到左下
};
//见设计稿(UI组件化->组件_按钮.sketch)
typedef NS_ENUM(NSUInteger, GMButtonType) {
GMButtonTypeGreen, //绿色无边框直角矩形
GMButtonTypeGreenRoundCorner, //绿色带6px的圆角无边框矩形
GMButtonTypeGreenSemicircle, //绿色半圆无边框矩形
GMButtonTypeGreenRoundCornerBorder, //绿色、6px圆角、1px的有边框的矩形
GMButtonTypeGreenSemicircleBorder, //绿色、半圆、1px的有边框的矩形
GMButtonTypeGreenRoundCornerGradient, //绿色、6px圆角、无边框的渐变矩形
GMButtonTypeGreenSemicircleGradient, //绿色、半圆、无边框的渐变矩形
GMButtonTypeRed, //红色无边框直角矩形
GMButtonTypeRedRoundCorner, //红色带6px的圆角无边框矩形
GMButtonTypeRedSemicircle, //红色半圆无边框矩形
GMButtonTypeRedRoundCornerBorder, //红色、6px圆角、1px的有边框的的矩形
GMButtonTypeRedRoundCornerGradient, //红色、6px圆角、无边框的渐变矩形
GMButtonTypeRedSemicircleGradient, //红色、半圆、无边框的渐变矩形
GMButtonTypeGraySemicircleBorder, //灰色、半圆、1px的有边框的矩形
};
@interface GMButton : UIButton
/**
* @author licong, 16-12-30 17:12:55
*
* 是否支持Button自适应热区,Apple人机交互指南建议,可点击控件的热区最好是44*44,默认是NO,不支持
*
* @since 5.8
*/
@property (nonatomic, assign) BOOL enableAdaptive;
/**
* @author licong, 16-12-30 17:12:31
*
* 自适应热区宽,默认是 44
*
* @since 5.8
*/
@property (nonatomic, assign) float adaptiveHotAreaWidth;
/**
* @author licong, 16-12-30 17:12:09
*
* 自适应热区高,默认是 44
*
* @since 5.8
*/
@property (nonatomic, assign) float adaptiveHotAreaHeight;
/**
* @author licong, 16-12-30 17:12:30
*
* 初始化方法
*
* @since 5.8
*/
- (void)setup __attribute__((objc_requires_super));
/**
* @author licong, 16-12-30 17:12:46
*
* 创建一个button,并设置好它的title、backgroundColor、size、titleColor
*
* @param title title
* @param bgColor backgroundColor
* @param size 大小
* @param titleColor title标题
*
* @return 返回创建好的button
*
* @since 5.8
*/
+ (instancetype)buttonWithTitle:(nullable NSString *)title
backgroundColor:(nullable UIColor *)bgColor
titleFontSize:(CGFloat)size
titleColor:(nullable UIColor *)titleColor;
/**
* @author licong
*
* UI组件化后自定制Button
*
* @param customType 工厂模式下的button类型
*
* @return 返回创建好的button
*
* @since 6.2.0
*/
+ (instancetype)buttonWithCustomType:(GMButtonType)customType;
/**
* @author licong, 16-12-30 17:12:29
*
* 根据Button的状态设置对应的背景颜色
*
* @param backgroundColor button的背景颜色
* @param state button的controlState
*
* @since 5.8
*/
- (void)setBackgroundColor:(UIColor *)backgroundColor forState:(UIControlState)state;
@end
NS_ASSUME_NONNULL_END