ios 可点击的富文本

#pragma mark -- 底部的客服电话提醒
- (void)createHintView
{
    UIImage *_image = loadBundleImageWithName(@"tips");
    UIImageView *_imageView = [[UIImageView alloc]init];
    [_imageView setFrame:CGRectMake(12, CGRectGetMaxY(self.walletPayView.frame) + 20, _image.size.width, _image.size.height)];
    _imageView.image = _image;
    [self.view addSubview:_imageView];

    
    NSMutableParagraphStyle * paragraphStyle = [NSMutableParagraphStyle new];
    //调整行间距
    paragraphStyle.lineSpacing= 6;
    NSDictionary*attriDict =@{NSParagraphStyleAttributeName:paragraphStyle};
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"有支付权限的用户,请改用安卓手机使用白条支付功能。如有疑问请联系客户热线:400-866-5566" attributes:attriDict];
    [attributedString addAttribute:NSFontAttributeName value:loadFont(12) range:NSMakeRange(0, attributedString.length)];
    [attributedString addAttribute:NSLinkAttributeName
                             value:@"tel://"
                             range:[[attributedString string] rangeOfString:@"400-888-5566"]];
    [attributedString addAttribute:NSForegroundColorAttributeName value:TFCOLOR_0093FF range:[[attributedString string] rangeOfString:@"400-888-5566"]];
    [attributedString addAttribute:NSForegroundColorAttributeName value:TFCOLOR_68758E range:[[attributedString string] rangeOfString:@"有支付权限的用户,请改用安卓手机使用白条支付功能。如有疑问请联系客户热线:"]];
    
    UITextView *_textview = [[UITextView alloc]init];
    _textview.backgroundColor = [UIColor clearColor];
    [_textview setFrame:CGRectMake(CGRectGetMaxX(_imageView.frame) + 3, CGRectGetMaxY(self.walletPayView.frame) + 10, kDEVICEWIDTH - 40, 80)];
    _textview.attributedText = attributedString;
    _textview.delegate = self; //不要忘记添加代理
    _textview.editable = NO;
    _textview.scrollEnabled = NO;
    [self.view addSubview:_textview];
}

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
    if ([[URL scheme] isEqualToString:@"tel"]) {
        [self telClicked];
        return NO;
    }
    return YES;
}

#pragma mark  -- clicked method
- (void)telClicked
{
    LJAlertNode *alert = [[LJAlertNode alloc] initWithMessage:@"每天00:00-24:00,我们竭诚为您服务" sureTitle:@"确认拨打" cancelTitle:@"取消" sureAction:^{
        [CHUtil  chTeleButtonPressed:LJServiceTeleNumber];
    } cancelAction:^{
    }];
    [alert show];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值