手势解锁怎么整天主教十字手势图形

手势解锁的实现
//& ViewController.m
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet lockView *lockV
@property (weak, nonatomic) IBOutlet UIImageView *imageV
@implementation ViewController
- (void)viewDidLoad {
self.lockView.delegate =
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage
imageNamed:@"Home_refresh_bg"]];
&&& [super
viewDidLoad];
&&& // Do any
additional setup after loading the view, typically from a
-(void)lockViewDelegate:(lockView *)lockView
anonValue:(NSString *)buttonValue andPrintcreenImage:(UIImage
*)printScreenImage{
NSLog(@"代理获取的密码%@",buttonValue);
self.imageView.image = printScreenI
&&& UIAlertView
*alt = [[UIAlertView alloc]initWithTitle:buttonValue message:nil
delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定",
&&& [alt show
- (void)didReceiveMemoryWarning {
&&& [super
didReceiveMemoryWarning];
&&& // Dispose
of any resources that can be recreated.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//& lockView.m
//& 手势解锁
#import "lockView.h"
@interface lockView()
@property(nonatomic,assign) CGFloat lockBtnWH;
@property(nonatomic,strong) UIBezierPath *
@property(nonatomic,strong) NSMutableString *btnV
// 保存移动时的当前P
@property(nonatomic,assign) CGPoint moveP
// 保存最后一个被选中的B
@property(nonatomic,assign) CGPoint selcetedMoveP
#import "lockView.h"
#define lockBtnCount 9
#define columeCount 3
#define lineCount 3
@implementation lockView
-(NSMutableString *)btnValue{
(_btnValue == nil) {
_btnValue = [NSMutableString string];
&&& return
-(void)awakeFromNib{
NSLog(@"111");
&&& UIImage
*backImage =& [UIImage
imageNamed:@"gesture_node_normal"];
self.lockBtnWH = backImage.size.
计算九宫格XY方向控件间距
&&& CGFloat
marginX = (self.frame.size.width - columeCount * self.lockBtnWH) /
(columeCount + 1);
&&& CGFloat
marginY = (self.frame.size.height - lineCount * self.lockBtnWH) /
(lineCount +1);
创建9个Btn添加到视图----改变了图片的Frame 调用layoutS
&&& for (int i =
0; i & lockBtnC i++) {
UIButton *lockBtn = [[UIButton alloc]init];
lockBtn.tag =
[lockBtn setImage:[UIImage imageNamed:@"gesture_node_normal"]
forState:UIControlStateNormal];
[lockBtn setImage:[UIImage imageNamed:@"gesture_node_highlighted"]
forState:UIControlStateSelected];
//& 计算控件XY坐标
CGFloat X = marginX + (backImage.size.width + marginX) * (i %
columeCount);
CGFloat Y = marginY + (backImage.size.width + marginY) * (i /
columeCount);
lockBtn.userInteractionEnabled = NO;
lockBtn.selected = YES;
[lockBtn setFrame:CGRectMake(X, Y, self.lockBtnWH,
self.lockBtnWH)];
[self addSubview:lockBtn];
-(void)layoutSubviews{
计算九宫格XY方向控件间距
NSLog(@"222");
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent
&&& UITouch
*touch = touches.anyO
&&& CGPoint
touchPoint =& [touch locationInView:self];
&&& UIBezierPath
*path = [UIBezierPath bezierPath];
每次按下时清空上次获取的密码
self.btnValue =
(UIButton *btn in self.subviews) {
[btn.layer& containsPoint:touchPoint]
if ( CGRectContainsPoint(btn.frame, touchPoint)) {
&&&&&&&&&&
&&&&&&&&&&&
path.lineWidth = 10;
&&&&&&&&&&&
&&&&&&&&&&&
self.path =
&&&&&&&&&&&
&&&&&&&&&&&
[path moveToPoint:btn.center];
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent
&&& UITouch
*touch = touches.anyO
&&& CGPoint
movePoint = [touch locationInView:self];
self.movePoint = moveP
(UIButton *btn in self.subviews) {
if ( CGRectContainsPoint(btn.frame, movePoint)&
&&& !btn.selected) {
&&&&&&&&&&&
&&&&&&&&&&&
[self.btnValue appendFormat:@"%ld",btn.tag];
&&&&&&&&&&&
&&&&&&&&&&&
btn.selected = YES;
&&&&&&&&&&&
self.selcetedMovePoint = btn.
&&&&&&&&&&&
&&&&&&&&&&&
[self.path addLineToPoint:btn.center];
&&&&&&&&&&&&
setNeedsDisplay];
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent
取消所有Btn的选中状态
(UIButton *btn in self.subviews) {
if (btn.selected) {
&&&&&&&&&&&
btn.selected = NO;
清空Btn之外的小尾巴
self.movePoint = self.selcetedMoveP
//& 调用代理之前必须清空小尾巴
([self.delegate
respondsToSelector:@selector(lockViewDelegate:anonValue:andPrintcreenImage:)])
[self.delegate lockViewDelegate:self anonValue:self.btnValue
andPrintcreenImage:[self printScreenAtSomeRect] ];
NSLog(@"绘制的密码是%@",self.btnValue);
必须在清空被选中btn之间路径之前调用代理方法,保证截图可以得到绘制的密码图案
清空被选中Btn之间的路径
&&& self.path =
setNeedsDisplay];
-(UIImage *)printScreenAtSomeRect{
UIGraphicsBeginImageContextWithOptions(self.frame.size, NO,
&&& CGContextRef
ctx = UIGraphicsGetCurrentContext();
&&& [self.layer
renderInContext:ctx];
&&& UIImage
*lockImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
&&& return
- (void)drawRect:(CGRect)rect {
绘制Btn区域之外的小尾巴
&&& UIBezierPath
*path = [UIBezierPath bezierPath];
path.lineWidth = 10;
moveToPoint:self.selcetedMovePoint];
addLineToPoint:self.movePoint];
&&& [[UIColor
whiteColor] set];
//& 渲染btn之间的路径
&&& [self.path
渲染小尾巴
&&& // Drawing
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。您现在的位置:&&&&&&&&&&&&&&&&&正文
漂亮的手机九宫格解锁图案大全:唯美手机九宫格解锁图案汇总
来源:本站原创
作者:佚名
在智能手机盛行的当下,手机解锁图案对于大家而言并不陌生。不少手机屏幕、应用开启(如支付宝)都设置了手势解锁锁,手机解锁图案也就诞生了。当然,一般情况下,大家都会设置易记且自己非常熟悉的手机解锁图案,以防忘记。但对于某些技术宅来说,寻常的手机解锁图案是他们看不上眼的。这里,就和大家分享一组碉堡的手机解锁图案大全。
手机解锁图案出现在我们生活的每个角落
  这组碉堡的手机解锁图案大全最先出现在微博上,发布者是。这组解锁图案大全最大的特点就是类似小时候玩的九宫图中的一笔画,即用一笔画在九宫图中完成图案创作。这些手机解锁图案以对称设计为主,但整体解锁过程相当复杂,旁人围观一次也需要细细琢磨一下。当然,这些复杂的手机解锁图案也确实能带给一些技术宅们非一般的解锁乐趣。本组图中,作者还很贴心地将完成过程写上,喜欢这些手机解锁图案的网友可以自己也来设置一个。
  一起来看看:
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
碉堡的手机解锁图案
大三角,起点是中心
六芒星阵,轨迹自己猜
小三角,起点是第二行第三个
小折线,起点是第一行第二个
91正,起点是中心。
91反,起点也是中心
【阅读:次】

我要回帖

更多关于 画十字手势 的文章

 

随机推荐