Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zekunyan/ttgpuzzleverify
By completing image puzzle game, TTGPuzzleVerify is a more user-friendly verification tool on iOS, which is highly customizable and easy to use. 体验更友好的拼图验证控件
https://github.com/zekunyan/ttgpuzzleverify
animation custom-puzzle-shape ios objective-c puzzle ui verification
Last synced: about 20 hours ago
JSON representation
By completing image puzzle game, TTGPuzzleVerify is a more user-friendly verification tool on iOS, which is highly customizable and easy to use. 体验更友好的拼图验证控件
- Host: GitHub
- URL: https://github.com/zekunyan/ttgpuzzleverify
- Owner: zekunyan
- License: mit
- Created: 2016-12-11T17:09:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-11T18:35:53.000Z (almost 8 years ago)
- Last Synced: 2024-11-15T23:06:19.001Z (4 days ago)
- Topics: animation, custom-puzzle-shape, ios, objective-c, puzzle, ui, verification
- Language: Objective-C
- Homepage:
- Size: 4.2 MB
- Stars: 361
- Watchers: 7
- Forks: 62
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TTGPuzzleVerify
[![CI Status](http://img.shields.io/travis/zekunyan/TTGPuzzleVerify.svg?style=flat)](https://travis-ci.org/zekunyan/TTGPuzzleVerify)
[![Version](https://img.shields.io/cocoapods/v/TTGPuzzleVerify.svg?style=flat)](http://cocoapods.org/pods/TTGPuzzleVerify)
[![License](https://img.shields.io/cocoapods/l/TTGPuzzleVerify.svg?style=flat)](http://cocoapods.org/pods/TTGPuzzleVerify)
[![Platform](https://img.shields.io/cocoapods/p/TTGPuzzleVerify.svg?style=flat)](http://cocoapods.org/pods/TTGPuzzleVerify)![Screenshot](https://github.com/zekunyan/TTGPuzzleVerify/raw/master/Resources/TTGPuzzleVerify.jpeg)
![Gif](https://github.com/zekunyan/TTGPuzzleVerify/raw/master/Resources/TTGPuzzleVerify.gif)
## What
By completing **image puzzle game**, TTGPuzzleVerify is a **more user-friendly** verification tool on iOS, which is highly customizable and easy to use. It supports square, circle, classic or custom puzzle shape. User can complete the verification by sliding horizontally, vertically or directly dragging the puzzle block.## Features
* More user-friendly
* Highly Customizable
* Classic, square, circle or custom puzzle shape
* Slide horizontally or vertically or drag the puzzle directly## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
iOS 7 and later.## Installation
TTGPuzzleVerify is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "TTGPuzzleVerify"
```## Usage
`TTGPuzzleVerifyView`### Basic use
```
// Import
#import- (void)viewDidLoad {
[super viewDidLoad];
// Create TTGPuzzleVerifyView instance
_puzzleVerifyView = [[TTGPuzzleVerifyView alloc] initWithFrame:CGRectMake(20, 20, 320, 200)];
[self.view addSubview:_puzzleVerifyView];
// Set image
_puzzleVerifyView.image = [UIImage imageNamed:@"pic"];
// Set the puzzle blank position
_puzzleVerifyView.puzzleBlankPosition = CGPointMake(200, 40);
// Set init puzzle position
_puzzleVerifyView.puzzlePosition = CGPointMake(10, 40);
// Callback
[_puzzleVerifyView setVerificationChangeBlock:^(TTGPuzzleVerifyView *view, BOOL isVerified) {
if (isVerified) {
// User complete the verification
}
}];
}// On slide changed
- (IBAction)onSliderChange:(UISlider *)sender {
// Update position
_puzzleVerifyView.puzzleXPercentage = sender.value;
}```
### API
#### Puzzle pattern types
```
/**
* TTGPuzzleVerifyView pattern type
*/
typedef NS_ENUM(NSInteger, TTGPuzzleVerifyPattern) {
TTGPuzzleVerifyClassicPattern = 0, // Default
TTGPuzzleVerifySquarePattern,
TTGPuzzleVerifyCirclePattern,
TTGPuzzleVerifyCustomPattern
};// Puzzle pattern, default is TTGPuzzleVerifyClassicPattern
@property (nonatomic, assign) TTGPuzzleVerifyPattern puzzlePattern;// Custom path for puzzle shape. Only work when puzzlePattern is TTGPuzzleVerifyCustomPattern
@property (nonatomic, strong) UIBezierPath *customPuzzlePatternPath;
```#### Complete the puzzle with animation
```
/**
Complete verification. Call this with set the puzzle to its original position and fill the blank.@param withAnimation if show animation
*/
- (void)completeVerificationWithAnimation:(BOOL)withAnimation;
```#### Callback
```
/**
* Verification changed callback delegate
*/
@protocol TTGPuzzleVerifyViewDelegate
@optional
- (void)puzzleVerifyView:(TTGPuzzleVerifyView *)puzzleVerifyView didChangedVerification:(BOOL)isVerified;- (void)puzzleVerifyView:(TTGPuzzleVerifyView *)puzzleVerifyView didChangedPuzzlePosition:(CGPoint)newPosition
xPercentage:(CGFloat)xPercentage yPercentage:(CGFloat)yPercentage;
@end// Callback block and delegate
@property (nonatomic, weak) id delegate; // Callback delegate
@property (nonatomic, copy) void (^verificationChangeBlock)(TTGPuzzleVerifyView *puzzleVerifyView, BOOL isVerified); // verification changed callback block
```#### Puzzle image
```
@property (nonatomic, strong) UIImage *image; // Image for verification
```#### Puzzle size and position
```
// Puzzle rect size,not for TTGPuzzleVerifyCustomPattern pattern
@property (nonatomic, assign) CGSize puzzleSize;// Puzzle blank position
@property (nonatomic, assign) CGPoint puzzleBlankPosition;// Puzzle current position
@property (nonatomic, assign) CGPoint puzzlePosition;// Puzzle current X and Y position percentage, range: [0, 1]
@property (nonatomic, assign) CGFloat puzzleXPercentage;
@property (nonatomic, assign) CGFloat puzzleYPercentage;
```#### Puzzle verification
```
// Verification
@property (nonatomic, assign) CGFloat verificationTolerance; // Verification tolerance, default is 8
@property (nonatomic, assign, readonly) BOOL isVerified; // Verification boolean
```#### Style
```
/**
* Style
*/// Puzzle blank alpha, default is 0.5
@property (nonatomic, assign) CGFloat puzzleBlankAlpha;// Puzzle blank inner shadow
@property (nonatomic, strong) UIColor *puzzleBlankInnerShadowColor; // Default: black
@property (nonatomic, assign) CGFloat puzzleBlankInnerShadowRadius; // Default: 4
@property (nonatomic, assign) CGFloat puzzleBlankInnerShadowOpacity; // Default: 0.5
@property (nonatomic, assign) CGSize puzzleBlankInnerShadowOffset; // Default: (0, 0)// Puzzle shadow
@property (nonatomic, strong) UIColor *puzzleShadowColor; // Default: black
@property (nonatomic, assign) CGFloat puzzleShadowRadius; // Default: 4
@property (nonatomic, assign) CGFloat puzzleShadowOpacity; // Default: 0.5
@property (nonatomic, assign) CGSize puzzleShadowOffset; // Default: (0, 0)
```## Example
For more information, you can download the zip and run the example.## Author
zekunyan, [email protected]
## License
TTGPuzzleVerify is available under the MIT license. See the LICENSE file for more info.