ios - 复制CALayer

标签 ios pdf uiview calayer

我想从 UIView 创建 PDF。
现在我想复制图层并将其调整为 DIN A4 页面大小。

CGRect A4PageRect = CGRectMake(0, 0, 595, 842);
CALayer *myLayer = [pdfView layer];
myLayer.bounds = pageRect;

但是这个 cody 调整了我屏幕上可见层的大小。

如何复制图层内容以调整其大小以适合 A4 页面?

谢谢你的帮助,朱利安

最佳答案

FWIW,您可以制作 CALayer 的浅拷贝通过:

( swift 3)

let tmp = NSKeyedArchiver.archivedData(withRootObject: myLayer)
let copiedCA = NSKeyedUnarchiver.unarchiveObject(with: tmp) as! CALayer

(或您正在使用的任何子类。例如 CAShapeLayer )

感谢:https://stackoverflow.com/a/35345819/1452758

关于ios - 复制CALayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10058752/

相关文章:

IOS NSDate 格式不正确

java - PDF 文件被下载两次 - IE8

ios - Xcode:当网站缩放时,UIWebView 拉动刷新动画不居中

解析PDF文件

pdf - 纯 javascript 中的 Apache FOP 替代方案

ios - 调用touchescancelled而不是touchesend

iphone - 仅在 iPad 上出现 "Application windows are expected to have a root view controller at the end of application launch"错误

ios - Swift 如何知道布局是否在 layoutIfNeeded() 之后完成

ios - 使用http方案深度链接iOS

ios - iOS 中的假名(非汉字)手写识别