NSAttributedString'in nasıl alınacağını ve iPad'de Çekirdek Metin'de nasıl kullanacağımı anlamaya çalışıyorum. Ben WWDC videolardan birini izledi slaytları (ancak hiçbir kaynak kodu) sahiptir (110) ve onu, bir NSAttributedString oluşturmak sonra sadece bir CTFramesetterRef koydu açıklar:NSAttributedString, iOS'ta Temel Metin'de kullanabilir miyim?
CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica-Bold"), 24.0, NULL);
NSString* unicodeString = NSLocalizedString(@"TitleString", @"Window Title");
CGColorRef color = [UIColor blueColor].CGColor; NSNumber* underline = [NSNumber numberWithInt:kCTUnderlineStyleSingle|kCTUnderlinePatternDot];
NSDictionary* attributesDict = [NSDictionary dictionaryWithObjectsAndKeys:helveticaBold, (NSString*)kCTFontAttributeName, color, (NSString*)kCTForegroundColorAttributeName, underline, (NSString*)kCTUnderlineStyleAttributeName, nil];
NSAttributedString* stringToDraw = [[NSAttributedString alloc] initWithString:unicodeString attributes:attributesDict];
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(stringToDraw);
CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, NULL);
CFRelease(framesetter);
CTFrameDraw(frame, context);
CFRelease(frame);
Ama bu çalıştığınızda, onu
Passing argument 1 of 'CTFramesetterCreateWithAttributedString' from incompatible pointer type
CFAttributedString Are ve NSAttributedString 'ücretsiz köprülü': hata atıyor? Bu sadece OSX'de bunun doğru olduğunu bir yere okudum, ama Apple'ın kendi demolarında böyle yapması ...
Teşekkürler!
: -Joe
gösterilme noktalı altı çizili olsun başardık? Metin altındaki sade tek alt çizgiyi aldım. – learner2010