此代码可以很好地使 url 出现在 UITextview
UITextView * descriptionTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 50, 300, 300)];
descriptionTextView.textColor = [UIColor whiteColor];
descriptionTextView.dataDetectorTypes = UIDataDetectorTypeLink;
descriptionTextView.font = [UIFont fontWithName:@"Helvetica" size:16];
descriptionTextView.backgroundColor = [UIColor clearColor];
descriptionTextView.text = @"Click to go to the google website, http://www.google.com ";
descriptionTextView.autocorrectionType = UITextAutocorrectionTypeNo;
descriptionTextView.keyboardType = UIKeyboardTypeDefault;
descriptionTextView.returnKeyType = UIReturnKeyDone;
descriptionTextView.editable = NO;
descriptionTextView.tag = 1;
[self.view addSubview:descriptionTextView];
问题是我写的整个网址都出现了,http://www.google.com
有没有办法只用一个词来包含链接?因此,用户只能看到以蓝色书写的“Goggle”,当他们点击该作品时,它会打开 safari。
非常感谢,-代码