我想更改NSView
的大小/位置而不影响其图层变换。
任何线索为何self.frame
不响应其图层的大小/位置更改?
// This exists in a NSView category
- (void)setLayerFrame:(CGRect)frame
{
[CATransaction begin];
[CATransaction setDisableActions:YES];
self.layer.bounds = (CGRect){CGPointZero, frame.size};
self.layer.position = frame.origin;
[CATransaction commit];
// Always logs "{{0, 0}, {0, 0}}"
NSLog(@"frame => %@", NSStringFromRect(self.frame));
}