2012-11-11 27 views
0

有沒有辦法繪製全屏疊加,然後在上面畫一個標籤+文本框?如何在其上繪製全屏疊加和文本+文本字段?

我已經做了:

當用戶點擊按鈕,屏幕應該被疊加覆蓋。

AppDelegate.m按鈕操作方法我寫

NSRect frame = [[NSScreen mainScreen] frame]; 
self.mainWindow = [[NSWindow alloc] initWithContentRect:frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; 
[self.mainWindow setAcceptsMouseMovedEvents:YES]; 
[self.mainWindow setOpaque:NO]; 
[self.mainWindow setLevel:CGShieldingWindowLevel()]; 
[self.mainWindow setBackgroundColor:[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:0.7]]; 
[self.mainWindow orderFrontRegardless]; 
NSApplicationPresentationOptions options = NSApplicationPresentationDisableProcessSwitching + NSApplicationPresentationHideDock + NSApplicationPresentationDisableForceQuit + NSApplicationPresentationDisableSessionTermination + NSApplicationPresentationDisableHideApplication; 
[NSApp setPresentationOptions:options]; 

它的工作不錯,但沒有任何動畫&我真的不知道如何繪製對象(標籤/文本框)在它?

要麼我應該將此方法移動到另一個類中嗎?

回答

1

爲動畫,有很多種方法..標識做

mainWindow.alphaValue = 0; 
[mainWindow orderFrontRegardless]; 
[[mainWindow animator] setAlphaValue:1.0]; 

爲標籤,只需添加的NSTextField一個巨大的NSFont,作爲一個子視圖

NSTextField *label = ... 
[[mainWindow contentView] addSubview:label]; 

附:就像與標籤一樣,您可以添加任何其他視圖:)