zekunyan/TTGPuzzleVerify
À propos
By completing image puzzle game, TTGPuzzleVerify is a more user-friendly verification tool on iOS, which is highly customizable and easy to use. 体验更友好的拼图验证控件
Design et médiasWhat you can do
- Native UIKit core with SwiftUI and Objective-C interoperability.
- Image, remote image, or generated gradient puzzle backgrounds.
- Classic, square, circle, and custom UIBezierPath puzzle shapes.
- Horizontal, vertical, or free two-axis dragging.
Progression mesurée des étoiles
- in 24h
- -1
- in 7 days
- -1
- in 15 days
- -1
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
README.md
OriginalTTGPuzzleVerify

TTGPuzzleVerify is a native iOS puzzle verification component. It supports image or gradient puzzle backgrounds, built-in and custom puzzle paths, configurable verification behavior, behavior metrics, and UIKit / SwiftUI / Objective-C integration from one shared core.
Highlights
- Native UIKit core with SwiftUI and Objective-C interoperability.
- Image, remote image, or generated gradient puzzle backgrounds.
- Classic, square, circle, and custom
UIBezierPathpuzzle shapes. - Horizontal, vertical, or free two-axis dragging.
- Manual verification or automatic verification with configurable tolerance.
- Success snap, failure feedback, reset, retry, and lock states.
- Rich result payload with offsets, elapsed time, drag distance, interaction count, and optional track samples.
- CocoaPods and Swift Package Manager support for iOS 16+.
Architecture

The component is organized as one shared TTGPuzzleVerifyView core. Integration surfaces configure the same rendering, pattern, interaction, verification, and metrics modules, so SwiftUI, UIKit, and Objective-C demos stay behaviorally consistent.
Installation
CocoaPods
platform :ios, '16.0'
use_frameworks!
pod "TTGPuzzleVerify"
Swift Package Manager
Add this repository as an iOS 16+ package dependency. The package product is TTGPuzzleVerify.
Quick Start

The editable quick start source lives in Resources/Marketing/quick_start.html, built from real screenshots under Resources/Marketing/assets.
SwiftUI wrapper
import TTGPuzzleVerify
struct PuzzleVerifyRepresentable: UIViewRepresentable {
@Binding var isVerified: Bool
func makeUIView(context: Context) -> TTGPuzzleVerifyView {
let view = TTGPuzzleVerifyView()
view.image = UIImage(named: "background")
let configuration = TTGPuzzleVerifyConfiguration()
configuration.puzzlePattern = .classicPattern
configuration.puzzleSize = CGSize(width: 86, height: 86)
configuration.allowedAxes = .both
configuration.autoSnapWhenWithinTolerance = true
view.applyConfiguration(configuration)
view.puzzleBlankPosition = CGPoint(x: 220, y: 96)
view.verificationChangeBlock = { _, verified in
isVerified = verified
}
return view
}
}
UIKit configuration
import TTGPuzzleVerify
let puzzleView = TTGPuzzleVerifyView()
puzzleView.image = UIImage(named: "background")
let configuration = TTGPuzzleVerifyConfiguration()
configuration.puzzlePattern = .circlePattern
configuration.puzzleSize = CGSize(width: 92, height: 92)
configuration.allowedAxes = .horizontal
configuration.verificationTolerance = 7
puzzleView.applyConfiguration(configuration)
puzzleView.puzzleBlankPosition = CGPoint(x: 210, y: 20)
puzzleView.resetVerification()
Objective-C UIKit
#import <TTGPuzzleVerify/TTGPuzzleVerify-Swift.h>
TTGPuzzleVerifyView *puzzleView = [[TTGPuzzleVerifyView alloc] init];
TTGPuzzleVerifyConfiguration *configuration = [[TTGPuzzleVerifyConfiguration alloc] init];
configuration.puzzlePattern = TTGPuzzleVerifyPatternClassicPattern;
configuration.allowedAxes = TTGPuzzleVerifyAllowedAxesBoth;
configuration.autoSnapWhenWithinTolerance = YES;
[puzzleView applyConfiguration:configuration];
puzzleView.puzzleBlankPosition = CGPointMake(220, 96);
[puzzleView resetVerification];
Image background puzzle
let configuration = TTGPuzzleVerifyConfiguration()
configuration.puzzlePattern = .classicPattern
configuration.allowedAxes = .horizontal
configuration.autoSnapWhenWithinTolerance = true
puzzleView.image = UIImage(named: "pic3")
puzzleView.applyConfiguration(configuration)
puzzleView.puzzleBlankPosition = CGPoint(x: 200, y: 20)
puzzleView.resetVerification()
Examples
The repository includes two runnable example apps:
- Objective-C UIKit example: run
pod installfromExamples/ObjCExample, then openExamples/ObjCExample/TTGPuzzleVerify.xcworkspace. - Swift example with UIKit and SwiftUI demos: run
pod installfromExamples/SwiftExample, then openExamples/SwiftExample/TTGPuzzleVerifySwiftExample.xcworkspace.
Key APIs
Pattern
public enum TTGPuzzleVerifyPattern: Int {
case classicPattern
case squarePattern
case circlePattern
case customPattern
}
Drag axes
public enum TTGPuzzleVerifyAllowedAxes: Int {
case horizontal
case vertical
case both
}
State
public enum TTGPuzzleVerifyState: Int {
case idle
case dragging
case verified
case failed
case locked
}
Result
TTGPuzzleVerifyResult includes:
isVerifiedpuzzlePositionblankPositionxOffset/yOffsetelapsedTimedragDistanceinteractionCount
Configuration
Use TTGPuzzleVerifyConfiguration to apply behavior consistently:
puzzlePatternpuzzleSizeverificationToleranceallowedAxesautoSnapWhenWithinTolerancerecordsTrackmaxRetryCountstyle
Requirements
- iOS 16.0+
- Xcode 15+
Testing
Objective-C tests cover default configuration, clamping, percentage mapping, verification tolerance, callbacks, configuration/style application, failure locking, result creation, and track collection.
cd Examples/ObjCExample
pod install
xcodebuild -workspace TTGPuzzleVerify.xcworkspace -scheme TTGPuzzleVerify-Example -destination 'platform=iOS Simulator,name=iPhone 17' test
Marketing Assets
The editable HTML sources live in Resources/Marketing:
promo_poster.html->promo_poster.jpgarchitecture_diagram.html->architecture_diagram.jpgquick_start.html->quick_start.jpg
Author
zekunyan, [email protected]
License
TTGPuzzleVerify is available under the MIT license. See the LICENSE file for more info.
Explorer des projets similaires
Chargement…