第一节 控件transform属性
1.平移
//相对于开始位置平移
//self.exView.transform = CGAffineTransformMakeTranslation(100, 0); //相对于上一次位置平移
self.exView.transform = CGAffineTransformTranslate(self.exView.transform, 50, 0);
2.旋转
//相对于开始位置旋转
//self.exView.transform = CGAffineTransformMakeRotation(M_PI_4);
//相对于上一次位置旋转
self.exView.transform = CGAffineTransformRotate(self.exView.transform, M_PI_4);
3.缩放
//相对于开始位置缩放
//self.exView.transform = CGAffineTransformMakeScale(2, 2);
//相对于上一次位置缩放
self.exView.transform = CGAffineTransformScale(self.exView.transform, 2, 2);
第二节 UITabBarController
1.UITabBarController创建
UITabBarController *tabBar = [[UITabBarController alloc] init];
2.tabBarItem的掌握以及设置title/image/badgeValue属性
Vc.tabBarItem.title = @"标题";
Vc.tabBarItem.image = [UIImage imageNamed:@"image"];
Vc.tabBarItem.badgeValue = @"10";
3.结合storyboard搭建主流的框架(工程文件)
第三节 Modal跳转
1.掌握两个方法
1> - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion;
2> - (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion;
2.了解底层实现原理
第四节 UIView事件
1.了解事件类型(触摸,加速计,远程控制)
2.掌握UIEvent\UITounch
3.掌握以下方法
//开始触摸时调用
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
NSLog(@"%s",__func__);
}
//开始移动时调用
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}
//离开时调用
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}
//摸个系统事件(如打电话)会打断触摸g过程,调用。
-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}
4.掌握view屏幕拖动实现原理
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//获取touch对象
UITouch *touch = [touches anyObject];
//获取当前点
CGPoint curP = [touch locationInView:self];
//获取当前点
CGPoint preP = [touch previousLocationInView:self];
//计算偏移量
CGFloat offsetX = curP.x - preP.x;
CGFloat offsetY = curP.y - preP.y;
//修改控件形变
self.transform = CGAffineTransformTranslate(self.transform, offsetX, offsetY);
}
5.UIView不接收触摸的三种情况
1> userInteractionEnabled设置为NO
2> hidden设置为yes
3> alpha设置0.0~0.01
- 事件传递注意事项
1> 如果父控件不能接收触摸事件,那么子控件就不可能接收到触摸事件。
2> 发生触摸事件-》系统将事件加入UIApplication管理的队列中-》UIApplication取出最前面事件交给应用程序的主窗口-》主窗口依次找到最合适的视图来处理事件-》视图执行touches方法。
7.方法
1>- (nullable UIView *)hitTest:(CGPoint)point withEvent:(nullable UIEvent *)event;底层实现、使用。
2>- (CGPoint)convertPoint:(CGPoint)point toView:(nullable UIView *)view;
3>- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event;
第五节 手势(掌握常见手势、添加以及常用UIGestureRecognizerDelegate方法)
//点击
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(Tap:)];
tapGesture.delegate = self;
[_imageV addGestureRecognizer:tapGesture];
//长按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(LongPress:)];
longPress.delegate = self;
[_imageV addGestureRecognizer:longPress];
//轻扫
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(Swipe:)];
swipeGesture.direction = UITextLayoutDirectionLeft;
[_imageV addGestureRecognizer:swipeGesture];
//拖拽
UIPanGestureRecognizer *panGusture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(PanGusture:)];
[_imageV addGestureRecognizer:panGusture];
//捏合
UIPinchGestureRecognizer *pinchGusture = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(PinchGusture:)];
[_imageV addGestureRecognizer:pinchGusture];
//旋转
UIRotationGestureRecognizer *rotationGusture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(RotationGusture:)];
[_imageV addGestureRecognizer:rotationGusture];