iOS支持可扩展字符串吗?
iOS中是否支持可扩展字符串?iOS支持可扩展字符串吗?,ios,objective-c,Ios,Objective C,iOS中是否支持可扩展字符串? 我想创建一个下划线窗格,单击它,然后打开其他一些视图控制器。是的,它们在iOS中称为NSAttributedString 添加下划线的示例代码 NSString *str = @"Amit"; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str]; [attributedString addAttribute:NSU
我想创建一个下划线窗格,单击它,然后打开其他一些视图控制器。是的,它们在iOS中称为NSAttributedString 添加下划线的示例代码
NSString *str = @"Amit";
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
[attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, 4)];
更多信息@
要向该下划线添加链接,请签出以下代码:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Google Webpage"];
[attributedString addAttribute:NSLinkAttributeName
value:@"http://www.google.com"
range:[[attributedString string] rangeOfString:@"Google Webpage"]];
NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor greenColor],
NSUnderlineColorAttributeName: [UIColor lightGrayColor],
NSUnderlineStyleAttributeName: @(NSUnderlinePatternSolid)};
// assume that textView is a UITextView previously created (either by code or Interface Builder)
textView.linkTextAttributes = linkAttributes; // customizes the appearance of links
textView.attributedText = attributedString;
textView.delegate = self;
找到此源代码@是的,它们在iOS中称为NSAttributedString 添加下划线的示例代码
NSString *str = @"Amit";
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
[attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:NSMakeRange(0, 4)];
更多信息@
要向该下划线添加链接,请签出以下代码:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Google Webpage"];
[attributedString addAttribute:NSLinkAttributeName
value:@"http://www.google.com"
range:[[attributedString string] rangeOfString:@"Google Webpage"]];
NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor greenColor],
NSUnderlineColorAttributeName: [UIColor lightGrayColor],
NSUnderlineStyleAttributeName: @(NSUnderlinePatternSolid)};
// assume that textView is a UITextView previously created (either by code or Interface Builder)
textView.linkTextAttributes = linkAttributes; // customizes the appearance of links
textView.attributedText = attributedString;
textView.delegate = self;
已找到此源代码@