Core Animation实战三(图层几何学),【一步教学,一步到位

//calculate hour hand angle //calculate minute hand angle

CGFloat minsAngle = (components.minute / 60.0) * M_PI * 2.0;

//calculate second hand angle

CGFloat secsAngle = (components.second / 60.0) * M_PI * 2.0;

//设置锚点

self.hourLabel.layer.anchorPoint =self.minuteLabel.layer.anchorPoint =self.secondLabel.layer.anchorPoint = CGPointMake(0.5f, 0.9f);

//rotate hands

self.hourLabel.transform = CGAffineTransformMakeRotation(hoursAngle);

self.minuteLabel.transform = CGAffineTransformMakeRotation(minsAngle);

self.secondLabel.transform = CGAffineTransformMakeRotation(secsAngle);

}

  • (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

/*

#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

// Get the new view controller using [segue destinationViewController].

// Pass the selected object to the new view controller.

}

*/

@end

  • 坐标系和Hit Testing

CALayer 并不关心任何响应链事件,所以不能直接处理触摸事件或者手势。但是它有一系列的方法帮你处理事件: -containsPoint:-hitTest:

-containsPoint:接受一个在本图层坐标系下的CGPoint,如果这个点在图层frame范围内就返回YES

-hitTest:方法同样接受一个CGPoint类型参数,而不是BOOL类型,它返回图层本身,或者包含这个坐标点的叶子节点图层。这意味着不再需要像使用-containsPoint:那样,人工地在每个子图层变换或者测试点击的坐标。如果这个点在最外面图层的范围之外,则返回nil。

//

// HitTestingViewController.m

// LayerStudyDemo

//

// Created by apple on 2017/9/25.

// Copyright © 2017年 ZY. All rights reserved.

//

#import “HitTestingViewController.h”

@interface HitTestingViewController ()

@property (weak, nonatomic) IBOutlet UIView *wildView;

@property (nonatomic, strong) CALayer *innerLayer;

@end

@implementation HitTestingViewController

  • (void)viewDidLoad {

[super viewDidLoad];

[self creatInnerLayer];

}

-(void)creatInnerLayer{

self.innerLayer = [CALayer layer];

self.innerLayer.frame = CGRectMake((self.wildView.frame.size.width-100)/2, (self.wildView.frame.size.height-100)/2, 100.0f, 100.0f);

self.innerLayer.backgroundColor = [UIColor blueColor].CGColor;

//add it to our view

[self.wildView.layer addSublayer:self.innerLayer];

}

// containsPoint 判断较麻烦,需要把坐标转换图层成每个坐标系下的坐标

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

CGPoint point = [[touches anyObject] locationInView:self.view];

//将点击的点从以 self.view.layer 为父类的坐标系转到self.wildView.layer为父类的坐标系

point = [self.wildView.layer convertPoint:point fromLayer:self.view.layer];

if ([self.wildView.layer containsPoint:point]) {

//convert point to blueLayer’s coordinates

point = [self.innerLayer convertPoint:point fromLayer:self.wildView.layer];

if ([self.innerLayer containsPoint:point]) {

[[[UIAlertView alloc] initWithTitle:@“Inside innerLayer Layer”

message:nil

delegate:nil

cancelButtonTitle:@“OK”

otherButtonTitles:nil] show];

} else {

[[[UIAlertView alloc] initWithTitle:@“Inside wildView Layer”

message:nil

delegate:nil

cancelButtonTitle:@“OK”

otherButtonTitles:nil] show];

}

}

}

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!

img
img

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V:vip1024c 备注前端获取(资料价值较高,非无偿)
img

文末

技术是没有终点的,也是学不完的,最重要的是活着、不秃。

零基础入门的时候看书还是看视频,我觉得成年人,何必做选择题呢,两个都要。喜欢看书就看书,喜欢看视频就看视频。

最重要的是在自学的过程中,一定不要眼高手低,要实战,把学到的技术投入到项目当中,解决问题,之后进一步锤炼自己的技术。

自学最怕的就是缺乏自驱力,一定要自律,杜绝“三天打鱼两天晒网”,到最后白忙活一场。

高度自律的同时,要保持耐心,不抛弃不放弃,切勿自怨自艾,每天给自己一点点鼓励,学习的劲头就会很足,不容易犯困。

技术学到手后,找工作的时候一定要好好准备一份简历,不要无头苍蝇一样去海投简历,容易“竹篮打水一场空”。好好的准备一下简历,毕竟是找工作的敲门砖。

拿到面试邀请后,在面试的过程中一定要大大方方,尽力把自己学到的知识舒适地表达出来,不要因为是自学就不够自信,给面试官一个好的印象,面试成功的几率就会大很多,加油吧,骚年!

要自律,杜绝“三天打鱼两天晒网”,到最后白忙活一场。

高度自律的同时,要保持耐心,不抛弃不放弃,切勿自怨自艾,每天给自己一点点鼓励,学习的劲头就会很足,不容易犯困。

技术学到手后,找工作的时候一定要好好准备一份简历,不要无头苍蝇一样去海投简历,容易“竹篮打水一场空”。好好的准备一下简历,毕竟是找工作的敲门砖。

拿到面试邀请后,在面试的过程中一定要大大方方,尽力把自己学到的知识舒适地表达出来,不要因为是自学就不够自信,给面试官一个好的印象,面试成功的几率就会大很多,加油吧,骚年!

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

  • 10
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值