123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- //
- // backupsOptionTipView.m
- // 双子星云手机
- //
- // Created by xd h on 2024/7/25.
- //
- #import "backupsOptionTipView.h"
- @interface backupsOptionTipView ()<UITextViewDelegate>
- @end
- @implementation backupsOptionTipView
- - (id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
-
- self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
- [self drawAnyView];
-
- return self;
- }
- -(void)drawAnyView
- {
- UIView *whiteBgView = [[UIView alloc] init];
- whiteBgView.backgroundColor = [UIColor whiteColor];
- [self addSubview:whiteBgView];
- whiteBgView.layer.cornerRadius = 8;
- whiteBgView.layer.masksToBounds = YES;
-
- // [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.centerX.mas_equalTo(0);
- // make.width.mas_equalTo(300);
- // make.height.mas_equalTo(300);
- // make.centerY.mas_equalTo(0);
- // }];
-
-
- //温馨提示
- UILabel *titleLabel = [[UILabel alloc] init];
- titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
- titleLabel.textColor = [UIColor hwColor:@"#151515"];
- titleLabel.text = NSLocalizedString(@"File_upload_Record_clear_Tip_title",nil);
- titleLabel.textAlignment = NSTextAlignmentCenter;
- [whiteBgView addSubview:titleLabel];
-
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(25);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(20);
- }];
-
-
- UITextView *contentTV = [[UITextView alloc] init];
- contentTV.backgroundColor = [UIColor whiteColor];
- //contentTV.textColor = HW666666Color;//[UIColor hwColor:@"#151515" alpha:0.5];
- // contentTV.font = [UIFont systemFontOfSize:16.0];
- // contentTV.textAlignment = NSTextAlignmentCenter;
- contentTV.delegate = self;
- contentTV.editable = NO; //必须禁止输入,否则点击将弹出输入键盘
- contentTV.scrollEnabled = NO;
- [whiteBgView addSubview:contentTV];
-
- // 创建长按手势识别器
- UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)];
- // 设置长按手势的最小按压时间
- longPress.minimumPressDuration = 0.5; // 2
- // 将手势识别器添加到视图上
- [contentTV addGestureRecognizer:longPress];
-
- NSString *title1 = NSLocalizedString(@"backups_need_read_msg",nil);
- NSString *title2 = NSLocalizedString(@"backups_need_read_msg2",nil);
- NSString *title3 = NSLocalizedString(@"backups_need_read_msg3",nil);
- NSString *title4 = NSLocalizedString(@"backups_need_read_msg4",nil);
-
- NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@%@%@%@",title1,title2,title3,title4];
-
- NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
-
- [attrStr addAttribute:NSForegroundColorAttributeName value:[UIColor hwColor:@"#151515" alpha:0.5] range:NSMakeRange(0, attrStr.length)];
-
- NSRange redRange = NSMakeRange([fullTitle rangeOfString:title3].location, [fullTitle rangeOfString:title3].length);
- UIColor *noteColor =[UIColor hwColor:@"#01B7EA" alpha:1.0];
- [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
- [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:NSMakeRange(0, attrStr.length)];
-
- // 设置段落样式以实现水平中间对齐
- // NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- // paragraphStyle.alignment = NSTextAlignmentCenter; // 水平中间对齐
- // [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrStr.length)];
-
-
-
- //title3Label.attributedText = attrStr;
- [attrStr addAttribute:NSLinkAttributeName
- value:@"didclick1://"
- range:redRange];
- contentTV.attributedText = attrStr;
-
- //计算高度
- CGFloat textHeight = [fullTitle boundingRectWithSize:CGSizeMake(270, 1000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.height;
- textHeight += 40;
- [contentTV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(textHeight);
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.top.equalTo(titleLabel.mas_bottom).offset(10.0);
- }];
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,240,40);
- gl.startPoint = CGPointMake(0.0, 0.5);
- gl.endPoint = CGPointMake(1, 0.5);
- gl.colors = @[(__bridge id)[UIColor hwColor:@"#0BDDFD"].CGColor, (__bridge id)[UIColor hwColor:@"#048CFB"].CGColor];
- gl.locations = @[@(0), @(1.0f)];
-
- UIButton *rightbut = [[UIButton alloc] init];
- [rightbut.layer addSublayer:gl];
-
- rightbut.tag = 1;
- [rightbut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [rightbut setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:UIControlStateNormal];
- [rightbut setTitleColor:[UIColor hwColor:@"#FFFFFF"] forState:UIControlStateNormal];
- rightbut.titleLabel.font = [UIFont systemFontOfSize:16];
- rightbut.layer.cornerRadius = 8;
- rightbut.layer.masksToBounds = YES;
- [whiteBgView addSubview:rightbut];
-
- [rightbut mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-30);
- make.width.mas_equalTo(240);
- make.height.mas_equalTo(40);
- make.bottom.mas_equalTo(-25);
- }];
-
- [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(0);
- make.width.mas_equalTo(300);
- make.height.mas_equalTo(45 + textHeight + 10 + 65 + 20);
- make.centerY.mas_equalTo(-20);
- }];
-
-
- }
- #pragma mark ---- textView Delegate ----
- - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
- {
-
- if([[URL scheme] isEqualToString:@"didclick1"]){
- [self removeFromSuperview];
- if(_didClickButtonFun){
- _didClickButtonFun(10);
- }
- return NO;
- }
-
- return YES;
-
- }
- #pragma mark 拦截长按事件
- - (void)longPress{
- HLog(@"拦截长按事件")
- }
- #pragma mark 按钮事件
- - (void)didClickButtonFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
- HLog(@"%ld",tag);
-
- [self removeFromSuperview];
-
-
- if(_didClickButtonFun){
- _didClickButtonFun(tag);
- }
- }
- @end
|