我有一个UITextView包含包含电子邮件id‘的大字符串。当单击一个电子邮件id时,我必须打开MFMailComposeViewController,电子邮件id应该在UITextView下面。
我试过如下
textview.dataDetectorTypes = UIDataDetectorTypeAddress;
textview.dataDetectorTypes = UIDataDetectorTypeLink;发布于 2015-01-29 11:13:28
试试下面的代码
textview.text = @"user@example.com";
textview.dataDetectorTypes = UIDataDetectorTypeLink;
textview.editable = NO;它将检测它作为电子邮件地址,当你点击它将打开视图发送电子邮件。
发布于 2015-01-29 12:21:29
尝试使用NSAttributedString帮助NSRange,如下所示
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"Some String"];
[attString addAttribute:(NSString*)kCTUnderlineStyleAttributeName
value:[NSNumber numberWithInt:kCTUnderlineStyleSingle]
range:(NSRange){0,5}];您可以设置如下所需的颜色
[attString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,5)];https://stackoverflow.com/questions/28212961
复制相似问题