objective-c - 可以在 c 结构中使用 CATextLayer 吗?

标签 objective-c c struct core-animation

我需要将标签与 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/

相关文章:

ios - 如何计算字符串中所有字符的出现次数?

ios - 如何制作自定义对象的 NSMutableArray 属性的深拷贝

c - 确保具有多个返回值的递归函数 "Preserve"期望的结果

struct - 使用单元结构的真实示例是什么?

iOS检测UIButton Press Dynamic索引

ios - 如何从 Amazon SNS 获取订阅 ARN 以取消订阅

c - 使用枚举时,C 编译器如何将 false 理解为 false,将 true 理解为 true?

c - 指针算术 : By how much is y increased?

c - 如何从非动态分配的结构数组中删除所有数据

c++ - SunCC 5.12 到 5.14 和 "Types cannot be declared in anonymous union"