[英]Search for a string in a string and make it Bold in the original String
我知道如何檢查一個字符串( NSString
)是否包含另一個較小的字符串。
if ([string rangeOfString:@"bla"].location == NSNotFound) {
NSLog(@"string does not contain bla");
} else {
NSLog(@"string contains bla!");
// here I need to make that string bold
}
除此之外,如果我要得到該字符串,我想在原始字符串中將其設為粗體,那么有什么辦法可以使我的特定字符串變為粗體? 提前致謝...
您將必須使用NSAttributedString。 但是問題是顯示NSAttributedString。
在iOS 6.0中,標簽支持NSAttributedString,但需要第三方標簽的版本較少。
將TTTAttributedLabel鏈接用於NSAttributedString。
請參閱ios-using-tttattributedlabel-to-set-color-text-text鏈接以獲取參考。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.