Files
yinmeng-ios-store/yinmeng-ios/DingDangApp/V2Versions/Login/View/DDProtocolView.m

78 lines
3.2 KiB
Mathematica
Raw Normal View History

2023-12-07 10:50:21 +08:00
//
// DDProtocolView.m
// DingDangApp
//
// Created by apple on 2023/7/4.
//
#import "DDProtocolView.h"
2023-12-12 18:36:32 -08:00
#import "DDAppColor.h"
2023-12-07 10:50:21 +08:00
@implementation DDProtocolView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self addSubview:self.protocolLabel];
[self addSubview:self.submitBtn];
[self.submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.width.mas_equalTo(44);
make.centerY.equalTo(self);
make.right.equalTo(self.protocolLabel.mas_left).inset(5);
}];
} return self;
}
- (void)submitBtnClick {
self.submitBtn.selected = !self.submitBtn.isSelected;
}
- (UIButton *)submitBtn {
if (!_submitBtn) {
_submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
2023-12-12 18:36:32 -08:00
[_submitBtn setImage:[UIImage imageNamed:@"login_checkbox_uncheck"] forState:UIControlStateNormal];
[_submitBtn setImage:[UIImage imageNamed:@"login_checkbox_checked"] forState:UIControlStateSelected];
2023-12-07 10:50:21 +08:00
[_submitBtn addTarget:self action:@selector(submitBtnClick) forControlEvents:UIControlEventTouchUpInside];
[_submitBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
} return _submitBtn;
}
- (YYLabel *)protocolLabel {
if (!_protocolLabel) {
_protocolLabel = [[YYLabel alloc]init];
_protocolLabel.textColor = UIColor.whiteColor;
_protocolLabel.font = DDFont(11);
_protocolLabel.textAlignment = NSTextAlignmentCenter;
CGFloat width = [ToolsObject sizeWithText:@"我已阅读《啵柚语音用户协议》和《啵柚语音隐私政策》" andFont:DDFont(12) maxSize:CGSizeMake(375, 44) andlineSpacing:2].width;
_protocolLabel.frame = CGRectMake(0, 0, width, 44);
_protocolLabel.centerX = kWidth/2+22;
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"我已阅读《啵柚语音用户协议》和《啵柚语音隐私政策》"];
text.yy_alignment = NSTextAlignmentLeft;
text.yy_color = DDHEXColor(0x999999);
WeakSelf(ws)
2023-12-12 18:36:32 -08:00
[text yy_setTextHighlightRange:[text.string rangeOfString:@"《啵柚语音用户协议》"] color:[DDAppColor dd_subTitleColor] backgroundColor:[UIColor whiteColor] userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
2023-12-07 10:50:21 +08:00
if (ws.userBlock) {
ws.userBlock();
}
} longPressAction:nil];
2023-12-12 18:36:32 -08:00
[text yy_setTextHighlightRange:[text.string rangeOfString:@"《啵柚语音隐私政策》"] color:[DDAppColor dd_subTitleColor] backgroundColor:[UIColor whiteColor] userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
2023-12-07 10:50:21 +08:00
if (ws.privacyBlock) {
ws.privacyBlock();
}
} longPressAction:nil];
_protocolLabel.attributedText = text;
} return _protocolLabel;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end