Day-05

第一節(jié) 控件transform屬性

1.平移
//相對于開始位置平移
//self.exView.transform = CGAffineTransformMakeTranslation(100, 0); //相對于上一次位置平移
 self.exView.transform = CGAffineTransformTranslate(self.exView.transform, 50, 0);
2.旋轉(zhuǎn)
//相對于開始位置旋轉(zhuǎn)
//self.exView.transform = CGAffineTransformMakeRotation(M_PI_4);
//相對于上一次位置旋轉(zhuǎn)
 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);

第二節(jié) UITabBarController

1.UITabBarController創(chuàng)建
UITabBarController *tabBar = [[UITabBarController alloc] init];
2.tabBarItem的掌握以及設(shè)置title/image/badgeValue屬性
Vc.tabBarItem.title = @"標(biāo)題";
Vc.tabBarItem.image = [UIImage imageNamed:@"image"];
Vc.tabBarItem.badgeValue = @"10";
3.結(jié)合storyboard搭建主流的框架(工程文件)

第三節(jié) Modal跳轉(zhuǎn)

1.掌握兩個(gè)方法
1>  - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion;
2>  - (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion;
2.了解底層實(shí)現(xiàn)原理

第四節(jié) UIView事件

1.了解事件類型(觸摸,加速計(jì),遠(yuǎn)程控制)
2.掌握UIEvent\UITounch
3.掌握以下方法

//開始觸摸時(shí)調(diào)用
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    NSLog(@"%s",__func__);
}
//開始移動(dòng)時(shí)調(diào)用
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

}
//離開時(shí)調(diào)用
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}
//摸個(gè)系統(tǒng)事件(如打電話)會(huì)打斷觸摸g過程,調(diào)用。
-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
}

4.掌握view屏幕拖動(dòng)實(shí)現(xiàn)原理

-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //獲取touch對象
    UITouch *touch = [touches anyObject];
    //獲取當(dāng)前點(diǎn)
    CGPoint curP = [touch locationInView:self];
    //獲取當(dāng)前點(diǎn)
    CGPoint preP = [touch previousLocationInView:self];
     //計(jì)算偏移量
    CGFloat offsetX = curP.x - preP.x;
    CGFloat offsetY = curP.y - preP.y;
    //修改控件形變
    self.transform = CGAffineTransformTranslate(self.transform, offsetX, offsetY);
}

5.UIView不接收觸摸的三種情況
1> userInteractionEnabled設(shè)置為NO
2> hidden設(shè)置為yes
3> alpha設(shè)置0.0~0.01

  1. 事件傳遞注意事項(xiàng)
    1> 如果父控件不能接收觸摸事件,那么子控件就不可能接收到觸摸事件。
    2> 發(fā)生觸摸事件-》系統(tǒng)將事件加入U(xiǎn)IApplication管理的隊(duì)列中-》UIApplication取出最前面事件交給應(yīng)用程序的主窗口-》主窗口依次找到最合適的視圖來處理事件-》視圖執(zhí)行touches方法。
    7.方法
1>- (nullable UIView *)hitTest:(CGPoint)point withEvent:(nullable UIEvent *)event;底層實(shí)現(xiàn)、使用。
2>- (CGPoint)convertPoint:(CGPoint)point toView:(nullable UIView *)view;
3>- (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event;

第五節(jié) 手勢(掌握常見手勢、添加以及常用UIGestureRecognizerDelegate方法)

   //點(diǎn)擊
    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];
    //旋轉(zhuǎn)
    UIRotationGestureRecognizer *rotationGusture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(RotationGusture:)];
    [_imageV addGestureRecognizer:rotationGusture];
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容