使用模块"CALayer"作为类型

gal*_*lio 7 calayer swift

我想将ITSwitch从obj-c移植到swift.https://github.com/iluuu1994/ITSwitch.git

在ITSwitch.m中

@property (readonly, strong) CALayer *rootLayer;
Run Code Online (Sandbox Code Playgroud)

所以在快速写道:

var rootLayer:CALayer?
Run Code Online (Sandbox Code Playgroud)

但是代码给了我这个错误:

Use of module 'CALayer' as a type
Run Code Online (Sandbox Code Playgroud)

错误是什么意思?我怎么解决这个问题?

Nat*_*ook 14

如果您import QuartzCore.swift文件顶部添加,则错误将消失.错误消息本身似乎有点像bug.

  • 谢谢,它的工作原理.看来这个问题太容易了.我应该做更多的研究并自己解决 (3认同)