Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "893F1FEB1AE68CF1009D6A35"
BuildableName = "CoreLock.app"
BlueprintName = "CoreLock"
ReferencedContainer = "container:CoreLock.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "893F20041AE68CF1009D6A35"
BuildableName = "CoreLockTests.xctest"
BlueprintName = "CoreLockTests"
ReferencedContainer = "container:CoreLock.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "893F20041AE68CF1009D6A35"
BuildableName = "CoreLockTests.xctest"
BlueprintName = "CoreLockTests"
ReferencedContainer = "container:CoreLock.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "893F1FEB1AE68CF1009D6A35"
BuildableName = "CoreLock.app"
BlueprintName = "CoreLock"
ReferencedContainer = "container:CoreLock.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "893F1FEB1AE68CF1009D6A35"
BuildableName = "CoreLock.app"
BlueprintName = "CoreLock"
ReferencedContainer = "container:CoreLock.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "893F1FEB1AE68CF1009D6A35"
BuildableName = "CoreLock.app"
BlueprintName = "CoreLock"
ReferencedContainer = "container:CoreLock.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>CoreLock.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>893F1FEB1AE68CF1009D6A35</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>893F20041AE68CF1009D6A35</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
124 changes: 83 additions & 41 deletions CoreLock/CoreLock/Lib/View/CLLockInfoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}



Expand Down
4 changes: 3 additions & 1 deletion CoreLock/CoreLock/Lib/View/CLLockView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down