我需要将标签与 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 中的 Frameworks Group,然后执行添加->现有框架...选择 QuartzCore 和 CoreText,您应该一切顺利!
关于objective-c - 可以在 c 结构中使用 CATextLayer 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4668472/