diff --git a/CoreLock.xcodeproj/project.xcworkspace/xcuserdata/george.xcuserdatad/UserInterfaceState.xcuserstate b/CoreLock.xcodeproj/project.xcworkspace/xcuserdata/george.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..493e291
Binary files /dev/null and b/CoreLock.xcodeproj/project.xcworkspace/xcuserdata/george.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/CoreLock.xcodeproj/xcuserdata/george.xcuserdatad/xcschemes/CoreLock.xcscheme b/CoreLock.xcodeproj/xcuserdata/george.xcuserdatad/xcschemes/CoreLock.xcscheme
new file mode 100644
index 0000000..09cd1ec
--- /dev/null
+++ b/CoreLock.xcodeproj/xcuserdata/george.xcuserdatad/xcschemes/CoreLock.xcscheme
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CoreLock.xcodeproj/xcuserdata/george.xcuserdatad/xcschemes/xcschememanagement.plist b/CoreLock.xcodeproj/xcuserdata/george.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..572fe8a
--- /dev/null
+++ b/CoreLock.xcodeproj/xcuserdata/george.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,27 @@
+
+
+
+
+ SchemeUserState
+
+ CoreLock.xcscheme
+
+ orderHint
+ 0
+
+
+ SuppressBuildableAutocreation
+
+ 893F1FEB1AE68CF1009D6A35
+
+ primary
+
+
+ 893F20041AE68CF1009D6A35
+
+ primary
+
+
+
+
+
diff --git a/CoreLock/CoreLock/Lib/View/CLLockInfoView.m b/CoreLock/CoreLock/Lib/View/CLLockInfoView.m
index bdd3d7b..0ab9c61 100644
--- a/CoreLock/CoreLock/Lib/View/CLLockInfoView.m
+++ b/CoreLock/CoreLock/Lib/View/CLLockInfoView.m
@@ -13,55 +13,97 @@
-@implementation CLLockInfoView
+@implementation CLLockInfoView {
+ NSString *password;
+}
+
+- (void)redrawRect:(CGRect)rect path:(CGMutablePathRef)pathM {
+ //获取上下文
+ CGContextRef ctx = UIGraphicsGetCurrentContext();
+
+ //设置属性
+ CGContextSetLineWidth(ctx, CoreLockArcLineW);
+
+ //添加路径
+ CGContextAddPath(ctx, pathM);
+
+ //绘制路径
+ CGContextStrokePath(ctx);
+
+ //释放路径
+ CGPathRelease(pathM);
+}
+
+FOUNDATION_STATIC_INLINE CGMutablePathRef path(CGMutablePathRef pathM, NSUInteger i, CGFloat rectWH, CGFloat padding, CGFloat marginV) {
+ NSUInteger row = i % 3;
+ NSUInteger col = i / 3;
+
+ CGFloat rectX = (rectWH + marginV) * row + padding;
+
+ CGFloat rectY = (rectWH + marginV) * col + padding;
+
+ CGRect rect = CGRectMake(rectX, rectY, rectWH, rectWH);
+
+ CGPathAddEllipseInRect(pathM, NULL, rect);
+
+ return pathM;
+}
+
+- (CGMutablePathRef)plainPathWithRectWH:(CGFloat)rectWH marginV:(CGFloat)marginV padding:(CGFloat)padding {
+ CGMutablePathRef pathM =CGPathCreateMutable();
+ for (NSUInteger i=0; i<9; i++) {
+ if (!password.length || [password rangeOfString:[NSString stringWithFormat:@"%lu", (unsigned long)i]].location == NSNotFound) {
+ path(pathM, i, rectWH, padding, marginV);
+
+ [CoreLockCircleLineNormalColor set];
+ }
+ }
+
+ return pathM;
+}
+
+- (CGMutablePathRef)highlightpathWithRectWH:(CGFloat)rectWH marginV:(CGFloat)marginV padding:(CGFloat)padding {
+ CGMutablePathRef pathM =CGPathCreateMutable();
+ for (NSUInteger i=0; i<9; i++) {
+
+ if (password.length && [password rangeOfString:[NSString stringWithFormat:@"%lu", (unsigned long)i]].location != NSNotFound) {
+ path(pathM, i, rectWH, padding, marginV);
+
+ [CoreLockCircleLineSelectedColor set];
+ }
+
+ }
+
+ return pathM;
+}
-(void)drawRect:(CGRect)rect{
-
- //获取上下文
- CGContextRef ctx = UIGraphicsGetCurrentContext();
-
- //设置属性
- CGContextSetLineWidth(ctx, CoreLockArcLineW);
-
- //设置线条颜色
- [CoreLockCircleLineNormalColor set];
-
- //新建路径
- CGMutablePathRef pathM =CGPathCreateMutable();
-
- CGFloat marginV = 3.f;
- CGFloat padding = 1.0f;
- CGFloat rectWH = (rect.size.width - marginV * 2 - padding*2) / 3;
-
- //添加圆形路径
- for (NSUInteger i=0; i<9; i++) {
-
- NSUInteger row = i % 3;
- NSUInteger col = i / 3;
-
- CGFloat rectX = (rectWH + marginV) * row + padding;
-
- CGFloat rectY = (rectWH + marginV) * col + padding;
-
- CGRect rect = CGRectMake(rectX, rectY, rectWH, rectWH);
-
- CGPathAddEllipseInRect(pathM, NULL, rect);
- }
-
- //添加路径
- CGContextAddPath(ctx, pathM);
-
- //绘制路径
- CGContextStrokePath(ctx);
-
- //释放路径
- CGPathRelease(pathM);
+ [super drawRect:rect];
+
+ CGFloat marginV = 3.f;
+ CGFloat padding = 1.0f;
+ CGFloat rectWH = (rect.size.width - marginV * 2 - padding*2) / 3;
+
+ [self redrawRect:rect path:[self plainPathWithRectWH:rectWH marginV:marginV padding:padding]];
+ [self redrawRect:rect path:[self highlightpathWithRectWH:rectWH marginV:marginV padding:padding]];
}
+- (void)redraw:(NSNotification *)notif {
+ password = notif.userInfo[@"CLLockView"];
+ [self setNeedsDisplay];
+}
+- (void)awakeFromNib {
+ [super awakeFromNib];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(redraw:) name:@"CLLockView" object:nil];
+}
+
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
diff --git a/CoreLock/CoreLock/Lib/View/CLLockView.m b/CoreLock/CoreLock/Lib/View/CLLockView.m
index 60dd739..a91ac10 100644
--- a/CoreLock/CoreLock/Lib/View/CLLockView.m
+++ b/CoreLock/CoreLock/Lib/View/CLLockView.m
@@ -369,7 +369,9 @@ -(void)lockHandle:(NSSet *)touches{
//记录密码
[self.pwdM appendFormat:@"%@",@(itemView.tag)];
-
+
+ //通知InfoView
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"CLLockView" object:nil userInfo:@{@"CLLockView":self.pwdM}];
//计算方向:每添加一次itemView就计算一次
[self calDirect];