This commit is contained in:
2025-11-17 14:53:23 +08:00
parent d9bfc30c88
commit 1d215ffdb3
19 changed files with 208 additions and 39 deletions

View File

@@ -0,0 +1,16 @@
//
// KBMoneyBtn.h
// keyBoard
//
// Created by Mac on 2025/11/17.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface KBMoneyBtn : UIButton
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,68 @@
//
// KBMoneyBtn.m
// keyBoard
//
// Created by Mac on 2025/11/17.
//
#import "KBMoneyBtn.h"
#import "UIColor+Extension.h"
@implementation KBMoneyBtn
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self kb_setupUI];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
[self kb_setupUI];
}
return self;
}
- (void)kb_setupUI {
// #EDFFFD 0.72
// self.backgroundColor = [UIColor colorWithHex:0xEDFFFD alpha:0.72];
self.backgroundColor = [UIColor colorWithHex:0xEDFFFD];
// 0x02BEAC
[self setTitleColor:[UIColor colorWithHex:0x02BEAC] forState:UIControlStateNormal];
self.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
//
UIImage *icon = [UIImage imageNamed:@"shop_jbsmall_icon"];
if (icon) {
[self setImage:icon forState:UIControlStateNormal];
}
//
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
self.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
// 15 imageEdgeInsets / titleEdgeInsets
CGFloat spacing = 5.0;
self.imageEdgeInsets = UIEdgeInsetsMake(0, -spacing / 2.0, 0, spacing / 2.0);
self.titleEdgeInsets = UIEdgeInsetsMake(0, spacing / 2.0, 0, -spacing / 2.0);
//
self.adjustsImageWhenHighlighted = YES;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat h = CGRectGetHeight(self.bounds);
if (h <= 0) { return; }
//
self.layer.cornerRadius = h / 2.0;
self.clipsToBounds = YES;
}
@end