मैं महान TTTAttributedLabel (https://github.com/mattt/TTTAttributedLabel) जो IOS 6 के तहत आईओएस 5 के तहत ठीक काम करता है का उपयोग कर रहा हालांकि, मैं त्रुटि मिलती है थोड़ा जारी करें, ऐसा लगता है कि सेट संदेश किसी ऑब्जेक्ट को भेजा जा रहा है जिसे जारी किया गया है। डीबगर का उपयोग करके, मैंने 0x200020e0 po'd किया है जो एक CTFontRef प्रतीत होता है।(NSCFType सेट) आईओएस में न पहचाना गया चयनकर्ता 6
https://github.com/mattt/TTTAttributedLabel
कि कोड:
[label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
NSRange boldRange = [[mutableAttributedString string] rangeOfString:title options:NSCaseInsensitiveSearch];
NSRange strikeRange = [[mutableAttributedString string] rangeOfString:@"sit amet" options:NSCaseInsensitiveSearch];
UIFont *boldSystemFont = [UIFont boldSystemFontOfSize:20];
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)boldSystemFont.fontName, boldSystemFont.pointSize, NULL);
if (font) {
[mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)font range:boldRange];
[mutableAttributedString addAttribute:(NSString*)kCTForegroundColorAttributeName value:(__bridge id)font range:boldRange];
CFRelease(font);
}
return mutableAttributedString;
}];
उपयोग का उदाहरण यहाँ के रूप में:
po 0x200020e0
(int) $0 = 536879328 CTFont <name: .HelveticaNeueUI-Bold, size: 20.000000, matrix: 0x0>
CTFontDescriptor <attributes: <CFBasicHash 0x20001900 [0x3c2a4100]>{type = mutable dict, count = 1,
entries =>
1 : <CFString 0x3be2a768 [0x3c2a4100]>{contents = "NSFontNameAttribute"} = <CFString 0x3c292c14 [0x3c2a4100]>{contents = ".HelveticaNeueUI-Bold"}
}
यह मैं सीधे कोड जो TTTAttributedLabel सेट करने के लिए नेतृत्व एआरसीफाइड नहीं है इसलिए मैंने ब्रिज किए गए कास्ट में जोड़ा है (ऊपर देखें)। मैंने पूरे स्थान पर बरकरार रखने की कोशिश की है, लेकिन ऐसा लगता है कि यह समस्या हल नहीं होती है (जो प्रतीत होता है) कि CTFontRef बहुत जल्दी रिलीज़ हो रहा है (मुझे लगता है - अन्य सुझावों का स्वागत है)।
इस पर हल करने के तरीके पर कोई विचार और क्यों यह केवल आईओएस 6 सिम्युलेटर के तहत फसल है? अग्रिम में धन्यवाद।
क्षमा करें, बस ध्यान दिया गया है कि वहां संपादन बहुत अधिक समझ में नहीं आता है .. मुझे याद नहीं है कि मेरी कौन सी कुंजी का मतलब है लेकिन आप अपनी स्थिति में पता लगाने में सक्षम हो सकते हैं। मूल रूप से बहिष्कृत कुंजी का उपयोग नहीं करते हैं! – CMash