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
1 change: 1 addition & 0 deletions PatternLockApp/DrawPatternLockView.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
NSMutableArray *_dotViews;
}

@property (nonatomic, strong) UIView* lastSelectedDot;

- (void)clearDotViews;
- (void)addDotView:(UIView*)view;
Expand Down
5 changes: 4 additions & 1 deletion PatternLockApp/DrawPatternLockView.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ - (void)drawRect:(CGRect)rect
lastDot = dotView;
}

self.lastSelectedDot = lastDot;

CGPoint pt = [_trackPointValue CGPointValue];
NSLog(@"\t to: %f, %f", pt.x, pt.y);
CGContextAddLineToPoint(context, pt.x, pt.y);
Expand All @@ -73,7 +75,8 @@ - (void)addDotView:(UIView *)view {
if (!_dotViews)
_dotViews = [NSMutableArray array];

[_dotViews addObject:view];
if (view != nil)
[_dotViews addObject:view];
}


Expand Down
15 changes: 6 additions & 9 deletions PatternLockApp/DrawPatternLockViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface


- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
_paths = [[NSMutableArray alloc] init];
[self clearUphighlights];
_paths = [[NSMutableArray alloc] init];
}


Expand Down Expand Up @@ -115,15 +116,11 @@ - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {


- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// clear up hilite
DrawPatternLockView *v = (DrawPatternLockView*)self.view;
[v clearDotViews];
// clean line if touch ended not on dot
DrawPatternLockView *v = (DrawPatternLockView*)self.view;
[v drawLineFromLastDotTo:v.lastSelectedDot.center];
[v setNeedsDisplay];

for (UIView *view in self.view.subviews)
if ([view isKindOfClass:[UIImageView class]])
[(UIImageView*)view setHighlighted:NO];

[self.view setNeedsDisplay];

// pass the output to target action...
if (_target && _action)
Expand Down