ipad迷你手势闹特三,手势解锁,提示说两次就解锁了,怎么也解不开?嗯两次哪里?

今天看啥 热点:
猫猫学IOS(三十五)UI之Quartz2D仿真支付宝手势解锁_代理获得密码。,iosquartz2d
猫猫分享,必须精品
原创文章,欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u?viewmode=contents
源码:http://blog.csdn.net/u/article/details/
其实这个实现起来不难
第一步先放好主要的UI,一张背景图和一个View
第二部就是把9个button放到view中,设置好按钮的默认和选中图片。
注意:创建时候的模式是UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
创建9个按钮添加到自定view中
- (void)setup
for (int i = 0; i & 9; i++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:[UIImage imageNamed:@"gesture_node_normal"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"gesture_node_highlighted"] forState:UIControlStateSelected];
[self addSubview:btn];
btn.userInteractionEnabled = NO;
然后就是监听手指按下,移动,抬起时候的事件了,并且在相应的地方画线。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
CGPoint startPoint = [self getCurrentTouchPoint:touches];
UIButton *btn = [self getCurrentBtnWithPoint:startPoint];
btn.selected = YES;
[self.buttons addObject:btn];
btn.selected = YES;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
CGPoint movePoint = [self getCurrentTouchPoint:touches];
UIButton *btn = [self getCurrentBtnWithPoint:movePoint];
if (btn && btn.selected != YES)
btn.selected = YES;
[self.buttons addObject:btn];
self.currentPoint = moveP
[self setNeedsDisplay];
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
NSMutableString *result = [NSMutableString string];
for (UIButton *btn in self.buttons) {
[result appendFormat:@"%d", btn.tag ];
if ([self.delegate respondsToSelector:@selector(lockViewDidClick:andPwd:)]) {
[self.delegate lockViewDidClick:self andPwd:result];
[self.buttons makeObjectsPerformSelector:@selector(setSelected:) withObject:@(NO)];
[self.buttons removeAllObjects];
[self setNeedsDisplay];
self.currentPoint = CGPointZ
- (void)drawRect:(CGRect)rect
CGContextRef ctx =
UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);
i = 0; i & self.buttons.count; i++) {
UIButton *btn = self.buttons[i];
if (0 == i) {
CGContextMoveToPoint(ctx, btn.center.x, btn.center.y);
CGContextAddLineToPoint(ctx, btn.center.x, btn.center.y);
if (self.buttons.count != 0) {
CGContextAddLineToPoint(ctx, self.currentPoint.x, self.currentPoint.y);
[[UIColor colorWithRed:1/255.0 green:102/255.0 blue:172/255.0 alpha:0.5] set];
CGContextSetLineWidth(ctx, 10);
CGContextSetLineJoin(ctx, kCGLineJoinRound);
CGContextSetLineCap(ctx, kCGLineCapRound);
CGContextStrokePath(ctx);
还有两个里面抽取出来的代码
根据系统传入的UITouch集合获取当前触摸的点
根据系统传入的UITouch集合获取当前触摸的点
当初触摸的点
- (CGPoint)getCurrentTouchPoint:(NSSet *)touches
UITouch *touch =
[touches anyObject];
CGPoint point = [touch locationInView:touch.view];
根据触摸点获取触摸到的按钮
根据触摸点获取触摸到的按钮
触摸的按钮
- (UIButton *)getCurrentBtnWithPoint:(CGPoint)point
for (UIButton *btn in self.subviews) {
if (CGRectContainsPoint(btn.frame, point)) {
还有就是用代理来把设置好的密码传出去。用的是button的tag属性,可以看代码中。
#import &UIKit/UIKit.h&
@class NYLockView;
@protocol NYLockViewDelegate &NSObject&
- (void)lockViewDidClick:(NYLockView *)lockView andPwd:(NSString *)
@interface NYLockView : UIView
@property (nonatomic, weak)IBOutlet id&NYLockViewDelegate&
NSMutableString *result = [NSMutableString string];
for (UIButton *btn in self.buttons) {
[result appendFormat:@"%d", btn.tag ];
if ([self.delegate respondsToSelector:@selector(lockViewDidClick:andPwd:)]) {
[self.delegate lockViewDidClick:self andPwd:result];
相关搜索:
相关阅读:
相关频道:
Android教程最近更新8060酷派手机,手势锁住了,怎么解锁_百度知道
8060酷派手机,手势锁住了,怎么解锁
我有更好的答案
或者自己用刷机精灵的解锁功能试试,再没办法就刷机吧去售后免费解锁,麻烦的话去小店也可以解锁
酷派售后有这个技术,拿你的发票去就可以了。要不你就找外面的帮你解了。
然后给下一页
其他类似问题
为您推荐:
酷派手机的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁您的举报已经提交成功,我们将尽快处理,谢谢!
只能去刷机了。。。。ROOT了。。。。
可以用ADB工具或者刷机精灵。
大家还关注
(window.slotbydup=window.slotbydup || []).push({
id: '2081942',
container: s,
size: '1000,60',
display: 'inlay-fix'

我要回帖

更多关于 android手势解锁源码 的文章

 

随机推荐