Swift:如何将String列表转换为CGPoint列表?

Salocinx

我是Swift的完全新手,在网络上什么也没找到。如何转换以这种方式格式化的字符串:

let str:String = "0,0 624,0 624,-48 672,-48 672,192"

到CGPoint的数组?

卢卡·安格莱蒂(Luca Angeletti)

此解决方案使用CGPointFromStringiOS提供功能。

import UIKit

let res = str
    .components(separatedBy: " ")
    .map { CGPointFromString("{\($0)}") }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章