SlidingPuzzleView
is a simple view written in Swift for implement sliding puzzle. Create a view, set a couple properties and execute startPuzzle()
!
- Properties must set before executing
startPuzzle()
- SlidingPuzzleView frame width and height must be equal.
let width: CGFloat = 300
let puzzleView: SlidingPuzzleView = SlidingPuzzleView(frame: CGRect(0, 0, width, width))
puzzleView.level = .normal
puzzleView.puzzleImage = UIImage(named: "image")
puzzleView.delegate = self
puzzleView.startPuzzle()
Property | Type | Description |
---|---|---|
pieceBorderColor | UIColor | Piece border color |
pieceBorderWidth | CGFloat | Piece border width |
level | puzzleLevel | 4 difficulty levels. veryEasy(2 x 2), easy(3 x 3), normal(4 x 4), hard(5 x 5) |
swapDuration | Double | Duration for swap animation |
puzzleImage | UIImage | Image for puzzle |
delegate | puzzleDelegate | Delegate (puzzleComplete, puzzleSwapCount) |
swapCount | Int | The number of times that the user has moved a piece. |
kokonak, kokonak7@gmail.com
SlidingPuzzleView is available under the MIT license. See the LICENSE file for more info.