QMUIGhostButton.h
2.44 KB
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
/*****
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2019 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*****/
//
// QMUIGhostButton.h
// QMUIKit
//
// Created by QMUI Team on 2018/4/9.
//
#import "QMUIButton.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, QMUIGhostButtonColor) {
QMUIGhostButtonColorBlue,
QMUIGhostButtonColorRed,
QMUIGhostButtonColorGreen,
QMUIGhostButtonColorGray,
QMUIGhostButtonColorWhite,
};
/**
* 用于 `QMUIGhostButton.cornerRadius` 属性,当 `cornerRadius` 为 `QMUIGhostButtonCornerRadiusAdjustsBounds` 时,`QMUIGhostButton` 会在高度变化时自动调整 `cornerRadius`,使其始终保持为高度的 1/2。
*/
extern const CGFloat QMUIGhostButtonCornerRadiusAdjustsBounds;
/**
* “幽灵”按钮,也即背景透明、带圆角边框的按钮
*
* 可通过 `QMUIGhostButtonColor` 设置几种预设的颜色,也可以用 `ghostColor` 设置自定义颜色。
*
* @warning 默认情况下,`ghostColor` 只会修改文字和边框的颜色,如果需要让 image 也跟随 `ghostColor` 的颜色,则可将 `adjustsImageWithGhostColor` 设为 `YES`
*/
@interface QMUIGhostButton : QMUIButton
@property(nonatomic, strong, nullable) IBInspectable UIColor *ghostColor; // 默认为 GhostButtonColorBlue
@property(nonatomic, assign) CGFloat borderWidth UI_APPEARANCE_SELECTOR; // 默认为 1pt
@property(nonatomic, assign) CGFloat cornerRadius UI_APPEARANCE_SELECTOR; // 默认为 QMUIGhostButtonCornerRadiusAdjustsBounds,也即固定保持按钮高度的一半。
/**
* 控制按钮里面的图片是否也要跟随 `ghostColor` 一起变化,默认为 `NO`
*/
@property(nonatomic, assign) BOOL adjustsImageWithGhostColor UI_APPEARANCE_SELECTOR;
- (instancetype)initWithGhostType:(QMUIGhostButtonColor)ghostType;
- (instancetype)initWithGhostColor:(nullable UIColor *)ghostColor;
@end
NS_ASSUME_NONNULL_END