zoukankan      html  css  js  c++  java
  • 核心动画

    UI-核心动画

    属性 说明  是否支持隐式动画

     anchorPoint 锚点、定位点  锚点的描述是相对于 *自己* x、y位置比例而言的 默认在图像中心点(0.5,0.5)的位置  决定图层的哪一个点 显示在中心点的位置

     backgroundColor 图层背景颜色

     borderColor 边框颜色

     borderWidth 边框宽度

     bounds 图层大小

     contents 图层显示内容,例如可以将图片作为图层内容显示

     contentsRect 图层显示内容的大小和位置

     cornerRadius 圆角半径

     doubleSided 图层背面是否显示,默认为YES

     frame 图层大小和位置,不支持隐式动画,所以CALayer中很少使用frame,通常使用bounds和position代替

     hidden 是否隐藏

     mask 图层蒙版

     maskToBounds 子图层是否剪切图层边界,默认为NO

     opacity 透明度 ,类似于UIView的alpha

     position 决定图层在父视图的位置 图层位于 *父视图* 中心点位置,类似于UIView的center

     shadowColor 阴影颜色

     shadowOffset 阴影偏移量

     shadowOpacity 阴影透明度,注意默认为0,如果设置阴影必须设置此属性

     shadowPath 阴影的形状

     shadowRadius 阴影模糊半径

     sublayers 子图层

     sublayerTransform 子图层形变

     transform 图层形变

     以上支持隐式动画的属性 本质是这些属性的变动默认隐含了CABasicAnimation动画实现

     使用核心动画需要导入#import <QuartzCore/QuartzCore.h>(现在不需要,系统默认导入了)

          Coreanimation 核心动画 简写CA

    CAlayer(图层)和UIview的关系

    1.在UIview中有一个layer属性作为根图层 ,根图层没有隐式动画。

       CALayer负责视图中显示的内容和动画

      UIview负责监听和响应事件

      由于CALayer在设计之初就考虑它的动画操作功能,CALayer很多属性在修改时都能形成动画效果,这种属性称为“隐式动画属性”。

     CALayer在修改他的属性时都能形成动画效果  这种动画效果  叫做隐式动画

       bounds:图层的大小,也就是本身的尺寸

    初始化 CALayer(这里的CAlayer是全局变量)

     mylayer =[[CALayer alloc]init];

        mylayer.bounds =CGRectMake(0, 0, 100, 100);

      设置中心点

        mylayer.position = self.view.center;

        mylayer.backgroundColor =[[UIColor redColor]CGColor];

      子图层是添加到根图层上的

        mylayer.borderWidth = 2;

        mylayer.borderColor =[[UIColor whiteColor]CGColor];

        [self.view.layer addSublayer:mylayer];

    触摸屏幕的时候

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

    //    设置阴影颜色,必须设置shadowOpacity 阴影颜色的透明度(默认是0, 完全透明)

        UITouch *touch =[touches anyObject];

        mylayer.backgroundColor =[[UIColor orangeColor] CGColor];

        mylayer.cornerRadius =200/2;

        mylayer.bounds =CGRectMake(0, 0, 200, 200);

        mylayer.shadowOffset =CGSizeMake(-2, -1);

        mylayer.shadowOpacity =1.0;

        mylayer.position= [touch locationInView:self.view];

    }

    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

        CGFloat width =CGRectGetWidth(mylayer.bounds);

        width= width==200? 100:200;

         mylayer.cornerRadius =10;

        mylayer.bounds =CGRectMake(0, 0, width, width);

       mylayer.backgroundColor = mylayer.backgroundColor == [UIColor yellowColor].CGColor ? [UIColor redColor].CGColor:[UIColor yellowColor].CGColor;

        

    }

  • 相关阅读:
    POJ 2723 Get Luffy Out(2-SAT)
    ZOJ 3613 Wormhole Transport
    HDU 4085 Peach Blossom Spring
    NBUT 1221 Intermediary
    NBUT 1223 Friends number
    NBUT 1220 SPY
    NBUT 1218 You are my brother
    PAT 1131. Subway Map (30)
    ZSTU OJ 4273 玩具
    ZSTU OJ 4272 最佳淘汰算法
  • 原文地址:https://www.cnblogs.com/popper123/p/4817591.html
Copyright © 2011-2022 走看看