繁体   English   中英

在Swift中将NSGlyph转换为CGGlyph(UInt32至UInt16)

[英]NSGlyph to CGGlyph in Swift (UInt32 to UInt16)

如何从NSGlyph转换为CGGlyph?

        let ctGlyph = glyph as CGGlyph

我看到:

typealias CGGlyph = CGFontIndex
typealias CGFontIndex = UInt16

typealias NSGlyph = UInt32

那么我该如何进行类型转换呢?

我试过了:

let ctGlyph = glyph as CGGlyph

但这给了我:

错误:“ NSGlyph”不可转换为“ CGGlyph”

您不能强制转换,但可以使用初始化程序:

let ctGlyph = CGGlyph(glyph)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM