1.关于
版权信息:在info.plist文件中添加如下键值对
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021 MacUIDemo. All rights reserved.</string>
主动调用显示关于
[[NSApplication sharedApplication] orderFrontStandardAboutPanel:nil];// 调用了下面方法,参数nil
[[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:nil];



- (IBAction)mainMenu_about:(NSMenuItem *)sender {
/**
版权信息:在info.plist文件中添加如下键值对
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021 MacUIDemo. All rights reserved.</string>
等价
[[NSApplication sharedApplication] orderFrontStandardAboutPanel:nil];
[[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:nil];
*/
NSString *string = @"aaaaaaaaa\nbbbbbbbbbcccccccccc";
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setAlignment:NSTextAlignmentCenter];
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:string];
[attStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [string length])];
/**所有信息都为可选项*/
NSDictionary *info = @{
NSAboutPanelOptionApplicationIcon:[NSImage imageNamed:NSImageNameComputer],// 应用程序的图标
NSAboutPanelOptionApplicationName:@"应用名称",// 应用程序的名字
NSAboutPanelOptionApplicationVersion:@"1.0.0",// 应用程序Version版本
NSAboutPanelOptionVersion:@"1",// 应用程序Build版本
NSAboutPanelOptionCredits:attStr// 信用信息
};
[[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:info];
}


网友评论