PuzzleMaker
PuzzleMaker
是一个用 Swift 编写的库,可以从图像动态生成一系列拼图。
安装
最方便的方式是通过 Podfile 使用 Cocoapods
pod 'PuzzleMaker'
或者使用 Carthage 并在 Cartfile
中添加一行
github "PGSSoft/PuzzleMaker"
要求
iOS 8.4
用法
import PuzzleMaker
let puzzleMaker = PuzzleMaker(image: UIImage(named: "image")!, numRows: ViewController.numRows, numColumns: ViewController.numColumns)
puzzleMaker.generatePuzzles { throwableClosure in
do {
let puzzleElements = try throwableClosure()
for row in 0 ..< ViewController.numRows {
for column in 0 ..< ViewController.numColumns {
guard let puzzleElement = puzzleElements[row][column] else { continue }
let position = puzzleElement.position
let image = puzzleElement.image
let imgView = UIImageView(frame: CGRect(x: position.x, y: position.y, width: image.size.width, height: image.size.height))
imgView.image = image
self.view.addSubview(imgView)
}
}
} catch {
debugPrint(error)
}
}
}
贡献
欢迎在GitHub上为我们提交错误报告和pull请求:[https://github.com/PGSSoft/PuzzleMaker](https://github.com/PGSSoft/PuzzleMaker)。
许可
本项目遵守MIT许可证的条款提供开源。
关于
本项目由软件开发公司PGS Software维护。查看我们的其他开源项目,或联系我们开发您的产品。