我需要将标签与CATextLayer关联起来,所以我想:
.h.小时

#import <QuartzCore/QuartzCore.h>
#import <CoreText/CoreText.h>

typedef struct textLayerWithTag
{
    CATextLayer *textLayer;
    int tag;
}textLayerWithTag;

.m.公司`
textLayerWithTag textLayer1;

textLayer1.tag = 0;
textLayer1.textLayer = [[CATextLayer alloc] init];
textLayer1.textLayer.string = @"aaaa";
textLayer1.textLayer.frame = CGRectMake(0.f, 10.f, 320.f, 32.f);

[self.view.layer addSublayer:textLayer1.textLayer];`

但是当我试图构建它时,我有一个错误:
"_OBJC_CLASS_$_CATextLayer", referenced from:
objc-class-ref-to-CATextLayer in StructViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

有什么想法吗?:/

最佳答案

您可能没有将QuartzCore和CoreText框架链接到您的项目。右键单击XCODE中的框架组,然后执行添加->现有框架…选择QuartzCore和CoreText,你应该很好去!

关于objective-c - 可以在c结构中使用CATextLayer吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4668472/

10-09 06:25