2013-12-08 6 views
0

나는 AddressBook을 사용하여 모든 레코드의 배열을 가져온 다음 UITableView에 이름을 표시합니다.iOS의 주소록에서 연락처 이름의 일부를 과장합니까?

제 질문은 연락처 앱처럼 성함의 올바른 부분을 어떻게 정리할 수 있습니까? 엄청난 수의 if 문을 만들 수 있지만 더 쉬운 방법이 있는지 궁금해하고있었습니다. 여기

내가 이름을 검색하는거야 방법 : 사전에

_person = person; 
CFStringRef name = ABRecordCopyCompositeName(person); 
NSString *nameString = CFBridgingRelease(name); 

[self.textLabel setText:nameString]; 

감사합니다.

답변

0

예를 들어 NSAttributedString을 사용합니다 (문자열의 모든 부분에 대해 모든 속성을 변경할 수 있음). 물론 귀속 된 문자열을 사용하도록 UILabel을 만드십시오.

NSMutableAttributedString* attrStr = [NSMutableAttributedString attributedStringWithString:@"Hello World!"]; 
// for those calls we don't specify a range so it affects the whole string 
[attrStr setFont:[UIFont systemFontOfSize:12]]; 
[attrStr setTextColor:[UIColor grayColor]]; 
// now we only change the color of "Hello" 
[attrStr setTextColor:[UIColor redColor] range:NSMakeRange(0,5)];