zoukankan      html  css  js  c++  java
  • Core Animation演示

    相关代码展示:

    - (IBAction)toggleRoundCorners:(id)sender {

        

        [CATransaction setDisableActions:![_enableAnimations isOn]];

        [CATransaction setAnimationDuration:_animationDuration];

        

        [_layer setCornerRadius:([_layer cornerRadius] == 0.0 ? 25.0 : 0.0)];

    }

    - (IBAction)toggleColor:(id)sender {

        [CATransaction setDisableActions:![_enableAnimations isOn]];

        [CATransaction setAnimationDuration:_animationDuration];

        

        [_layer setBackgroundColor:([_layer backgroundColor] == [UIColor blueColor].CGColor ? [UIColor greenColor].CGColor : [UIColor blueColor].CGColor)]; 

    }

    - (IBAction)toggleBorder:(id)sender {

        

        [CATransaction setDisableActions:![_enableAnimations isOn]];

        [CATransaction setAnimationDuration:_animationDuration];

        [_layer setBorderWidth:([_layer borderWidth] == 0.0 ? 10 : 0.0)];

    }

    - (IBAction)toggleOpacity:(id)sender {

        

        [CATransaction setDisableActions:![_enableAnimations isOn]];

        [CATransaction setAnimationDuration:_animationDuration];

        

        [_layer setOpacity:([_layer opacity] == 1.0 ? 0.2 : 1.0)];

    }

    - (IBAction)toggleSize:(id)sender 

    {

        [CATransaction setDisableActions:![_enableAnimations isOn]];

        [CATransaction setAnimationDuration:_animationDuration];

        

        CGRect layerBounds = _layer.bounds;

        layerBounds.size.width  = (layerBounds.size.width == layerBounds.size.height) ? 250.0 : 200.0;

        [_layer setBounds:layerBounds];

        

        BTSAnchorPointLayer *anchorPointLayer = [[_layer sublayers] objectAtIndex:0];

        [anchorPointLayer setPosition:BTSCalculateAnchorPointPositionForLayer(_layer)];

    }

    - (void)beginAnimatingLayer

    {

        // Here we are creating an explicit animation for the layer's "transform" property.

        // - The duration (in seconds) is controlled by the user.

        // - The repeat count is hard coded to go "forever".

        

        CABasicAnimation *pulseAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];

        [pulseAnimation setDuration:_animationDuration];

        [pulseAnimation setRepeatCount:MAXFLOAT];

        

        // The built-in ease in/ ease out timing function is used to make the animation look smooth as the layer

        // animates between the two scaling transformations.

        [pulseAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

        

        // Scale the layer to half the size

        CATransform3D transform = CATransform3DMakeScale(0.50, 0.50, 1.0);

        

        // Tell CA to interpolate to this transformation matrix

        [pulseAnimation setToValue:[NSValue valueWithCATransform3D:CATransform3DIdentity]];

        [pulseAnimation setToValue:[NSValue valueWithCATransform3D:transform]];

        

        // Tells CA to reverse the animation (e.g. animate back to the layer's transform)

        [pulseAnimation setAutoreverses:_autoreverses];

        

        // Finally... add the explicit animation to the layer... the animation automatically starts.

        [_layer addAnimation:pulseAnimation forKey:kBTSPulseAnimation];

    }

    - (void)endAnimatingLayer

    {

        [_layer removeAnimationForKey:kBTSPulseAnimation];

    }

  • 相关阅读:
    SSM集成Mybatis和Druid
    SpringMVC集成Thymeleaf
    最简单的SpringMVC + Maven配置
    信息化平台架构设计
    TaskSchedule-任务调度系统设计
    Redis的类库封装设计
    [oracle] DBLINK +同义词,实现本地数据库访问另一台机器的数据库
    [Tomcat 部署问题] Undeployment Failure could not be redeployed ...
    [oracle原]访问局域网内出现“ORA-12541:TNS:无监听程序”
    [java插件]myeclipse添加插件
  • 原文地址:https://www.cnblogs.com/yulang314/p/3833158.html
Copyright © 2011-2022 走看看