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];
}
}
];
网友评论