Cocoa下实现SplashScreen

Cocoa下实现SplashScreen,第1张

概述#import <Cocoa/Cocoa.h> @interface SplashWindow : NSWindow- (id)initWithSplashImage:(NSString*)imgfile;@end //SplashWindow.m #import "SplashWindow.h"@implementation SplashWindow- (id)initWithSp
 
#import <Cocoa/Cocoa.h>
@interface SplashWindow : NSWindow- (ID)initWithSplashImage:(Nsstring*)imgfile;@end


//SplashWindow.m

#import "SplashWindow.h"@implementation SplashWindow- (ID)initWithSplashImage:(Nsstring*)imgfile{	NSRect screenRect = [[NSScreen mainScreen] frame]; // NSRect for screen		NSImage *backgroundImage = [NSImage imagenamed:imgfile];	NSSize size = [backgroundImage size];	CGRect contentRect = CGRectMake(screenRect.size.wIDth /2-size.wIDth/2,screenRect.size.height/2-size.height/2,size.wIDth,size.height);	[self setBackgroundcolor:[NScolor colorWithPatternImage:backgroundImage]];	self = [super initWithContentRect:contentRect							styleMask:NSborderlessWindowMask backing:NSbackingStoreBuffered								defer:NO];	[self orderFront:self ];	return self;}- (BOol)acceptsMouseMovedEvents{	return NO;}@end


//AppDelegate.h

#import <Cocoa/Cocoa.h>#import "SplashWindow.h"@interface AppDelegate : NSObject {   IBOutlet SplashWindow* _splashWindow;  }@end

//AppDelegate.m

#import "AppDelegate.h"@implementation AppDelegate- (voID)applicationWillFinishLaunching:(NSNotification *)aNotification {  	_splashWindow = [[SplashWindow alloc]initWithSplashImage:@"bg_splash"];}- (voID)dealloc{	[_splashWindow release];	[super dealloc];}- (voID)applicationDIDFinishLaunching:(NSNotification *)aNotification {    // hIDe the about Box after one second.  [NSTimer scheduledTimerWithTimeInterval: 5.0f                                    target:self                                  selector:@selector(closeSplashBox:)                                  userInfo:self                                   repeats:false];}- (voID)closeSplashBox:(NSTimer*)theTimer{	[_splashWindow close];}@end



总结

以上是内存溢出为你收集整理的Cocoa下实现SplashScreen全部内容,希望文章能够帮你解决Cocoa下实现SplashScreen所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1059857.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存