美文网首页
macOS App Main Menu 工具栏

macOS App Main Menu 工具栏

作者: 愤斗的小蚂蚁 | 来源:发表于2021-10-09 08:14 被阅读0次

1.关于
版权信息:在info.plist文件中添加如下键值对
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021 MacUIDemo. All rights reserved.</string>

主动调用显示关于
[[NSApplication sharedApplication] orderFrontStandardAboutPanel:nil];// 调用了下面方法,参数nil
[[NSApplication sharedApplication] orderFrontStandardAboutPanelWithOptions:nil];

image.png image.png image.png
- (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];
}
image.png image.png

相关文章

网友评论

      本文标题:macOS App Main Menu 工具栏

      本文链接:https://www.haomeiwen.com/subject/qdtxoltx.html