大佬教程收集整理的这篇文章主要介绍了iphone – iOS:Bold和Italic在同一个单词上,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
问题:如何显示类似“Hello,我的名字是Byte”的内容.请注意,Byte既是粗体又是斜体,而其他单词仍然正常.
我试过了:我认为coreText应该能够做到这一点,我只是无法找到正确的方法来做到这一点.我也使用了TTTAttributeLabel,并且不能使它既粗体又斜体.我有Three20加载,只是不知道使用哪个或什么. Webview不适用于我的背景.
作为对Carles Estevadeordal的回复:
UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(10,360,300,40)]; [webView setBACkgroundColor: [UIColor clearColor]]; [webView loadHTMLString:[NSString StringWithFormat:@"<html><body style=\"BACkground-color: transparent;\">Hello,my name is <b><i>Byte</b></i></body></html>"] baseURL:nil]; [self.view addSubview:webView];
TTTAttributedLabel *attLabel = [[TTTAttributedLabel alloc]initWithFrame:CGRectMake(x,y,xx,yy)]; NSString *text = @"Hello,my name is Byte"; [attLabel setText:text afterInheriTingLabelAttributesAndConfiguringWithBlock:^(NSMutableAttributedString *mutableAttributedString) { //font Helvetica with bold and italic UIFont *boldSystemFont = [UIFont fontWithName:@"Helvetica-BoldOblique" size:10]; CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName,boldSystemFont.pointSize,null); NSRange boldRange = [[mutableAttributedString String] rangeOfString:@"Byte" options:NSCaseInsensitiveSearch]; [mutableAttributedString addAttribute:(NSString *)kCTFontAttributENAME value:(__bridge id)font range:boldRange]; CFRelease(font); return mutableAttributedString; }];
以上是大佬教程为你收集整理的iphone – iOS:Bold和Italic在同一个单词上全部内容,希望文章能够帮你解决iphone – iOS:Bold和Italic在同一个单词上所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。