在Swift项目中导入Agens Geometry Kit(AGK)

时间:2014-08-20 08:02:57

标签: objective-c swift

我尝试将使用Objective-C编写的Agent Geometry Kit(https://github.com/hfossli/AGGeometryKit)导入到Swift项目中。

我首先将所有源文件复制到我的项目中,然后创建一个桥头文件,在其中导入我刚刚添加的所有头文件(看起来像这样https://gist.github.com/JeanCParis/97dc6c27c70a4f00dbb0

我的问题是,虽然我的项目现在可以使用所有导入的类和结构,但是像AGKQuad这样的联盟却没有。

我做错了什么,或者工作在Swift中不可用,如果是这样,我怎样才能最好地绕过这个问题?非常感谢提前!

让克里斯托夫

编辑:我仍然是开发IOS的新手,但是我不能创建一个Objective-C类,我可以从我的Swift项目中调用它来完成工作&#34;做好工作&#34 ;并告诉我我要找的结果?我试图做到这一点,遗憾的是它没有给我预期的结果,虽然可能是我还没有完全理解Agent Geometry Kit如何工作(该方法的作用来自github上的自述文件)< / p>
@implementation DoTheJob

- (UIImageView*)DoDaJob:(UIImage*)image {

    UIImageView *view = [[UIImageView alloc] initWithImage:image];
    [view.layer ensureAnchorPointIsSetToZero]; // set the anchor point to [0, 0] (this method keeps the same position)

    AGKQuad quad = view.layer.quadrilateral;
    quad.br.x += 600; // shift bottom right x-value with 20 pixels
    quad.br.y += 500; // shift bottom right y-value with 50 pixels

    view.layer.quadrilateral = quad; // the quad is converted to CATransform3D and applied
    printf("DoingDaJob");
    return view;
}

@end

这原则上是否应该起作用?

1 个答案:

答案 0 :(得分:0)

显然不支持C联盟。

我在编辑过的问题中发布的代码运行得很好,即使它可能不是最佳解决方案,但我只是误解了这个库的工作原理。