ios - 如何旋转 CAShapeLayer 及其图案?

标签 ios objective-c transform calayer

我有一个 CAShapeLayer,我可以使用 UIRotationGestureRecognizer 旋转它。但是在旋转时,它只旋转它的框架而不是它里面的填充图案。

        CAShapeLayer *shapeLayer = [finalShapeLayersArray objectAtIndex:indextobeRotated];
        CGPathRef path = createPathRotatedAroundBoundingBoxCenter(shapeLayer.path,recognizer.rotation);
        shapeLayer.path  = path;
        CGPathRelease(path);
        recognizer.rotation = 0;

Bu 这样做,它只会旋转 CAShapeLayer 的边界。我用图像填充了一个图案。我只是希望该模式也应该旋转。

最佳答案

您需要使用 CALayer's transform property 在图层上设置一个旋转变换相反(您不旋转形状路径,因为整个图层都将旋转)。

参见 this answer关于如何创建这样的转换。另见 Core Animation Function Reference对于可以创建/修改转换的所有函数。

关于ios - 如何旋转 CAShapeLayer 及其图案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20856811/

相关文章:

objective-c - NSWindow 鼠标事件

objective-c - 构建 xcode 5 iOs 7 时出现 "curl_rule_01 declared as an array with negative size"错误

objective-c - iOS + jqueryMobile 无法在加载 html 文件时捕获 webview 事件

MSBuild:Items + Batching + CreateItem + Transforms 问题

javascript - 如何获取 translateX 和 translateY 的值?

ios - iOS 的 UILocalNotification 中不显示操作和类别

ios - 当 Cocos2D 2.0 支持 NPOT 纹理时,为什么要使用纹理图集?

ios - Transloadit 缩略图结果图像的文件扩展名大写错误

algorithm - 如何将投影的 3D 矩形转换为 2D 轴对齐矩形

javascript - 使用 PhoneGap 在 iOS 上录音