【问题标题】:How to rotate CAShapeLayer object?如何旋转 CAShapeLayer 对象?
【发布时间】:2015-02-19 04:07:55
【问题描述】:

基本上我需要实现的是需要在加号图标和带有动画的复选标记之间切换的自定义按钮。作为第一步,我尝试使用 CAShapeLayer 创建水平线并尝试旋转某个角度。我无法弄清楚其中有什么问题。

 UIBezierPath *linePath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0,self.frame.size.width, 10)];

//shape layer for the line
CAShapeLayer *line = [CAShapeLayer layer];
line.backgroundColor = [UIColor redColor].CGColor;
line.path = [linePath CGPath];
line.fillColor = [[UIColor greenColor] CGColor];
line.frame = CGRectMake(0, 10, self.frame.size.width,10);
line.anchorPoint = CGPointMake(0.0, 0.5);
line.transform = CATransform3DMakeRotation(30, 0.0, 0.0, 1.0);
[self.layer addSublayer:line];

【问题讨论】:

    标签: ios objective-c core-animation uibezierpath cashapelayer


    【解决方案1】:

    变换使用弧度,所以你应该使用

    line.transform = CATransform3DMakeRotation(30 * M_PI/180, 0.0, 0.0, 1.0);
    

    【讨论】:

      【解决方案2】:

      我使用这个库来添加我添加的内容,http://code4app.net/ios/BZAnimationButton/5477ed87e24741f10bb03ca0

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-18
        • 1970-01-01
        相关资源
        最近更新 更多