core text 在iPad中怎样设置位置?
我在测试中发现,y坐标是反着的⋯⋯
哎⋯⋯

解决方案 »

  1.   

    大家有什么core text的例子吗?
    简单一点的最好
    stackoverflow 的就不要了,我几乎都看完了
      

  2.   

    http://www.cocoachina.com/bbs/read.php?tid-14889.html看看是不是这个
      

  3.   

    这个不好,一点都不好,都不能运行~~
    我贴一段能运行的:CGContextRef context = UIGraphicsGetCurrentContext();
    float viewHeight = self.bounds.size.height;
        CGContextTranslateCTM(context, 0, viewHeight);
        CGContextScaleCTM(context, 1.0, -1.0);
    CGContextSetTextMatrix(context, CGAffineTransformMakeScale(1.0, 1.0));

    CTFontRef font = CTFontCreateWithName(CFSTR("Times"), 48, NULL);
    CFStringRef keys[] = { kCTFontAttributeName };
    CFTypeRef values[] = { font };
    CFDictionaryRef attr = CFDictionaryCreate(NULL, 
      (const void **)&keys, 
      (const void **)&values,
      sizeof(keys) / sizeof(keys[0]), 
      &kCFTypeDictionaryKeyCallBacks, 
      &kCFTypeDictionaryValueCallBacks);

    CFAttributedStringRef attrString = CFAttributedStringCreate(NULL, CFSTR("Hello, World!"), attr);
    CFRelease(attr);
    CGMutablePathRef path = CGPathCreateMutable();
    CGRect bounds = CGRectMake(0,0,200,200);
    CGPathAddRect(path, NULL, bounds);



    /* draw the text */
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(attrString);
    CTFrameRef frame = CTFramesetterCreateFrame(framesetter,
    CFRangeMake(0, 0), path, NULL);
    CFRelease(framesetter);
    CFRelease(path);
    CTFrameDraw(frame, context);