我是 Swift 的新手,没有在网上找到任何东西。如何转换以这种方式格式化的字符串:
let str:String = "0,0 624,0 624,-48 672,-48 672,192"
到 CGPoint 的数组?
最佳答案
本方案使用iOS提供的CGPointFromString
函数。
import UIKit
let res = str
.components(separatedBy: " ")
.map { CGPointFromString("{\($0)}") }
关于ios - Swift:如何将字符串列表转换为 CGPoint 列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37816200/