gpt4 book ai didi

UITextView 中的 iOS 可点击文本

转载 作者:可可西里 更新时间:2023-11-01 03:31:50 26 4
gpt4 key购买 nike

有没有办法制作 UITextView 的可点击部分。其实我想使文字像

By clicking “Register” above, you are agreeing to the Terms of Services and Privacy Statement

服务条款应该是一个链接,隐私声明是另一个链接。通过点击那些我应该做的事情。

最佳答案

我用上面的代码使用 this project 完成了它

- (void)_configureTermsLabel
{
self.termsOfUseLabel.hidden = YES;
self.termsAndConditionsLabel = [[TTTAttributedLabel alloc] initWithFrame:self.termsOfUseLabel.frame];
self.termsAndConditionsLabel.font = [UIFont systemFontOfSize:14];
self.termsAndConditionsLabel.lineBreakMode = UILineBreakModeWordWrap;
self.termsAndConditionsLabel.numberOfLines = 0;

NSString *termsStr = NSLocalizedString(@"Terms of use", @"Terms of use");
NSString *privacyStr = NSLocalizedString(@"Privacy Policy", @"Privacy Policy");
NSString *andStr = NSLocalizedString(@"and", @"and");
NSString *conductStr = NSLocalizedString(@"Code of conduct", @"Code of conduct");
NSString *termsAndConditionsStr = [NSString stringWithFormat:@"%@ - %@ %@ %@", termsStr,
privacyStr, andStr, conductStr];
self.termsAndConditionsLabel.text = termsAndConditionsStr;

NSString *languageCode = [[GLQAppDelegate sharedDelegate] languageIdentifier];
NSURL *termsURL = [NSURL URLWithString:[NSString stringWithFormat:kGLQTermsOfUseURL, languageCode]];
NSURL *privacyURL = [NSURL URLWithString:[NSString stringWithFormat:kGLQPrivacyPolicyURL, languageCode]];
NSURL *conductURL = [NSURL URLWithString:[NSString stringWithFormat:kGLQCodeOfConductURL, languageCode]];

NSRange termsRange = [self.termsAndConditionsLabel.text rangeOfString:termsStr];
NSRange privacyRange = [self.termsAndConditionsLabel.text rangeOfString:privacyStr];
NSRange conductRange = [self.termsAndConditionsLabel.text rangeOfString:conductStr];

[self.termsAndConditionsLabel addLinkToURL:termsURL withRange:termsRange];
[self.termsAndConditionsLabel addLinkToURL:privacyURL withRange:privacyRange];
[self.termsAndConditionsLabel addLinkToURL:conductURL withRange:conductRange];
self.termsAndConditionsLabel.delegate = self;

self.termsAndConditionsLabel.userInteractionEnabled = YES;
[self.scrollView addSubview:self.termsAndConditionsLabel];
}

关于UITextView 中的 iOS 可点击文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14338229/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com