macOS桌面开发NSAlert的使用
1 简述
附加到窗口的模式对话框或工作表,可以定义标题,描述详情,图标,按钮等。
@interface NSAlert : NSObject
NSAlert
总体分为两类:
-
显示在应用程序中的提示框
- (void)beginSheetModalForWindow:(NSWindow *)sheetWindow completionHandler:(void (^ _Nullable)(NSModalResponse returnCode))handler API_AVAILABLE(macos(10.9));
-
单个警报,应用程序外的提示框
[alert runModal];
2 常用属性
@property (copy) NSString *messageText; // 主要提示信息
@property (copy) NSString *informativeText;// 其他提示信息
@property (null_resettable, strong) NSImage *icon; // 自定义图标,不设置会使用系统默认图标 NSApplicationIcon
/*!
typedef NS_ENUM(NSUInteger