NSImageView를 변형하기 위해 설정했습니다. 내 처음 시도 viewDidLoad의 레이어 백업 NSView 문제
self.imageView.wantsLayer = YES;
self.imageView.layer.transform = CATransform3DMakeRotation(1,1,1,1);
불행하게도 나는 단지
때때로 (아마도마다 5 실행)을 어떻게 변환 것을 발견했다. 사이에 NSLog 추가 일부 실행
self.imageView.layer
에 null을 확인했습니다. 전체 프로젝트의 상태가 아래 이미지에 표시됩니다.
그것은 생성 NSViewController에 콘센트가있는 매우 간단하여 200x200 NSImageView을합니다. 일부 실험에서는 설정 wantDisplay가 문제를 해결하지 못했지만 NSTimer에 변환을 넣으면 매번 작동합니다. 나는 이것이 왜 일어나는 지에 대한 설명을 좋아할 것이다. (나는 그것이 어떤 경쟁 조건으로 인한 것임을 짐작한다.)
저는 MacOS 10.12에서 Xcode 8을 사용하고 있습니다. 그러나 이것이 문제의 원인인지 의심 스럽습니다.
업데이트
wantsLayer
을 제거하고 미친 듯이 문제가 해결되지 않은 인터페이스 빌더에서 코어 애니메이션 레이어를 가능하게한다.
는 나도 내가 수도 실현 allowsImplicitAnimation 실험 후에 애니메이션을 시도 (내가 바라고 있었는지 확실하지 않았다)
// Sometimes works.. doesn't animate
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
context.duration = 1;
self.imageView.animator.layer.transform = CATransform3DMakeRotation(1,1,1,1);
} completionHandler:^{
NSLog(@"Done");
}];
또는
// Animates but only sometimes
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(1,1,1,1)];
animation.duration = 1;
[self.imageView.layer addAnimation:animation forKey:nil];