I'm working on a Cocoa app in Xcode.
I would like to create a splash screen using a .png file as the image content in the splash screen.
I've accomplished the following:
- The splash screen is displayed for 2 seconds when the app is launched
- The splash screen is displayed at the center of the screen
- The splash screen can't be minimized, moved or re-sized by the user
From my class:
IBOutlet NSView *customView;
IBOutlet NSImageView *splashScreen;
IBOutlet NSWindow *splashWindow;
Here's what I have so far in awakeFromNib
NSRect rect = NSMakeRect(0,0,421,231);
splashScreen = [[NSImageView alloc] initWithFrame:rect];
[splashScreen setImageScaling:NSScaleToFit];
[splashScreen setImage:[NSImage imageNamed:@"splash.png"]];
[customView addSubview:splashScreen];
CGFloat xPos = NSWidth([[splashWindow screen] frame])/2 - NSWidth([splashWindow frame])/2;
CGFloat yPos = NSHeight([[splashWindow screen] frame])/2 - NSHeight([splashWindow frame])/2;
[splashWindow setFrame:NSMakeRect(xPos, yPos, NSWidth([splashWindow frame]), NSHeight([splashWindow frame])) display:YES];
And then in applicationDidFinishLaunching:
sleep(2); /* Yeah. I know this is bad. No need to comment on that */
[splashWindow close];
Questions:
How do I bring the splash image to the front of every open window on the desktop?
The PNG is a rectangle but the tiny areas near the corners of the image should be transparent. However...the transparent spots just shows as white..How do I fix that?
How do I implement the feature where the image is closed if the user clicks on the image before it's closed automatically?
How do I set up a timer to close the window after 2-3 seconds? (NSTimer)