如何创建包含 CGAffineTransform
的 NSValue
实例?
UIKit 提供了[NSValue valueWithCGAffineTransform:]
,但 AppKit 没有。
我需要使用valueWithBytes:objCType:
静态方法吗?
最佳答案
CGAffineTransform 是一个结构
struct CGAffineTransform {
CGFloat a, b, c, d;
CGFloat tx, ty;
};
Key-Value Coding Programming Guide - Representing Non-Object Values中提到了如何处理结构的正确方法(包裹和展开结构)
CGAffineTransform transform;
NSValue *value = [NSValue valueWithBytes:&transform objCType:@encode(CGAffineTransform)];
关于macOS - [NSValue valueWithCGAffineTransform :],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54960554/