Objective-C 学习记录 - 1

Xcode中可以使用CABasicAnimation类实现动画效果

    CABasicAnimation *strokeAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];

    strokeAnimation.fromValue = @0.0;

    strokeAnimation.toValue = @1.0;

    strokeAnimation.duration = 2;

 

animationWithKeyPath的参数是字符串,特定的KeyPath字符串表示特定的动画效果

 

动画效果的参数由fromValue、toValue、beginpath、duration等属性改变,在不同的KeyPath下有不同的意义

 

在以上代码的例子中,KeyPath为@“strokeEnd”,其效果为沿路径绘制,fromValue和toValue分别代表起始位置和终止位置,有效区间为0(fromValue)-1(toValue),duration为动画速度,1为正常,数值越大速度越慢

 

动画的路径可以由(NS/UI)BezierPath实现

 

@property (strong, nonatomic) UIBezierPath *FullPath;


self.path = self.FullPath.CGPath;        //这里调用路径


-(UIBezierPath *) FullPath {

    if(!_FullPath){

        _FullPath = [[UIBezierPath alloc] init];

        [_FullPath moveToPoint:CGPointMake(0.0, 100.0)];

        [_FullPathaddLineToPoint:CGPointMake(0.0, -KLineWidth)];

        [_FullPath addLineToPoint:CGPointMake(100.0, -KLineWidth)];

        [_FullPath addLineToPoint:CGPointMake(100.0, 100.0)];

        [_FullPath addLineToPoint:CGPointMake(-KLineWidth / 2, 100.0)];

        [_FullPath closePath];
    }

    return _FullPath;

}

 

参考资料:http://www.cnblogs.com/wanghuaijun/p/5617645.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值