NSAlert

作者: 皮蛋豆腐酱油 | 来源:发表于2019-12-06 11:35 被阅读0次

    1.改大小(x,y动不了,高可以改)
    https://www.jianshu.com/p/8ce2a26cca40

    2.基本使用

        NSAlert *alert = [[NSAlert alloc] init];
        NSLog(@"frame = %@",NSStringFromRect(alert.window.frame));
        alert.icon = [NSImage imageNamed:@"警告2"];
        [alert addButtonWithTitle:@"确定"];//1000
        [alert addButtonWithTitle:@"取消"];//1001
        [alert setMessageText:@"xxx"];
        [alert setInformativeText:@"xxxxxxxxxxxxxxxxxx"];//英文
        [alert setAlertStyle:NSAlertStyleInformational];
        
        //开始显示告警
        [alert beginSheetModalForWindow:self.window
                      completionHandler:^(NSModalResponse returnCode){
                          //用户点击告警上面的按钮后的回调
                          NSLog(@"returnCode : %ld",(long)returnCode);
                          if ((long)returnCode == 1000) {
                              [self.window orderOut:nil];
                          }
                          
                      }
         ];
    

    相关文章

      网友评论

          本文标题:NSAlert

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