ICPatternLock is a screen lock for your app access. It's familiar to most people and intuitively clear, because a pattern is much more easy to remember. What is more, it's also convenient for developers to use, of course, and to extend.
To run the example project, clone the repo, and run pod install
from the Example directory first.
ICPatternLock is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ICPatternLock"
If you don't care much about the view display and some interactions, just use the ICPatternLockManager
to present the pattern
lock and receive the result.
Of cource you can cusomize your GUI(e.g. color & text & preference) in this way.
All what you need to do is just run your logic in the callback block.
Check out the Demo Project
to experience this.
if ([ICPatternLockManager isPatternSetted])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hint"
message:@"Pattern already setted"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
else
{
[ICPatternLockManager showSettingPatternLock:self
animated:YES
successBlock:^(ICPatternLockViewController *controller){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[controller dismissViewControllerAnimated:YES completion:nil];
});
}];
}
[ICPatternLockManager showVerifyPatternLock:self
animated:YES
forgetPwdBlock:^(ICPatternLockViewController *controller){
NSLog(@"OMG~ forgot my pattern!~");
}
successBlock:^(ICPatternLockViewController *controller){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[controller dismissViewControllerAnimated:YES completion:nil];
});
}];
[ICPatternLockManager showModifyPatternLock:self
animated:YES
successBlock:^(ICPatternLockViewController *controller) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[controller dismissViewControllerAnimated:YES completion:nil];
});
}];
Use api below to custom your own resource (text display & color) & preference (e.g. node size, key table)
All key is defined in PLPreferencesKeyDef.h
PLResourceTextKeyDef.h
PLResourceColorKeyDef.h
Change all the value or maybe just one of them if you like.
#pragma mark - Resource Bridge
+ (void)loadTextResource:(NSDictionary *)textInfo;
+ (void)loadColorResource:(NSDictionary *)colorInfo;
#pragma mark - Preferences
- (void)setPreferencesValue:(id)value forKey:(NSString *)key;
#pragma mark - PatternHandler
+ (void)setCustomizedPatternHandler:(id<ICPatternHandlerProtocol>)handler;
If you want to assemble this to your own logic, using ICPatternLockViewController
directly, it has enough api for user.
What's more, you can use ICPatternLockView
to achive other goal if you like, imagination has no end!
_ivanC
ICPatternLock is available under the MIT license. See the LICENSE file for more info.