2014-02-07 4 views
0

NSWindowController에 NSPanel을 제공합니다. NSPanel의 제목 표시 줄에있는 작은 빨간 버튼을 누르면 다른 애니메이션으로 사라지는 방식을 변경하고 싶습니다. 어떻게해야합니까? 내가 바꿀 수있는 - (void) closeButtonPressed와 같은 것이 있는가? NSWindow의 - (void) close가 내가 원하는 것처럼 작동하지 않기 때문에. 내가 제시 할 때 나는 이런 식으로 작업을 수행합니다
빨간색 닫기 버튼을 클릭하면 NSPanel 닫기 애니메이션을 어떻게, 어디에서 변경할 수 있습니까?

[self.imagePanelController.previewPanel setFrame:NSRectFromCGRect(CGRectMake(self.window.frame.origin.x + self.window.frame.size.width/4 , self.window.frame.origin.y + self.bounds.size.height/4, self.ciImage.extent.size.width, self.ciImage.extent.size.height)) display:YES animate:YES]; 

내가 다시 새로운 프레임을 설정하고 패널 닫기 버튼을 누르면, 그 애니메이션을하고 싶습니다. 어떤 아이디어?

+0

, 윈도우 (AN [애니메이션 동작을]이 https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/ NSWindow_Class/Reference/Reference.html # // apple_ref/occ/instm/NSWindow/setAnimationBehavior :). – CodaFi

답변

0

그래서 나 자신을 알아 냈고, 그것은 나를 위해 작동합니다. 그게 최선의 해결책인지는 모르겠지만, 내가 필요한 것입니다. 누군가가 비슷한 것을 찾고 있다면 나는 이것을 게시합니다.

NSPanel의 closeButton을 가져 와서 패널에 애니메이션을 적용하는 방식으로 패널을 닫으라는 동작을 수행합니다. 레이어로 일을 렌더링과 애니메이션의 짧은

NSButton *closeButton = [self.imagePanelController.previewPanel standardWindowButton:NSWindowCloseButton]; 
    [closeButton setTarget:self]; 
    [closeButton setAction:@selector(closePanel)]; 

- (void)closePanel 
{ 

    int calcX = self.window.frame.size.width - self.bounds.size.width; 
    int x = self.window.frame.origin.x + calcX; 
    int y = self.window.frame.origin.y; 
    int width = self.bounds.size.width; 
    int height = self.bounds.size.height; 

    [self.imagePanelController.previewPanel setFrame:NSRectFromCGRect(CGRectMake(x, y, width, height)) display:YES animate:YES]; 
    [self.imagePanelController.previewPanel close]; 

}