NSButton *closeBtn = [[NSButton alloc] initWithFrame:NSMakeRect(276, 42, 70, 42)];
NSMutableParagraphStyle *closeBtnStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
closeBtnStyle setAlignment:NSTextAlignmentCenter];
NSDictionary *closeBtnAttrs = [NSDictionary dictionaryWithObjectsAndKeys:closeBtnStyle,
NSParagraphStyleAttributeName,
[NSFont fontWithName:@"PingFangSC-Regular" size:12.0],
NSFontAttributeName,
一个color,
NSForegroundColorAttributeName,
nil];
NSMutableAttributedString *closeBtnStr = [[NSMutableAttributedString alloc] initWithString:@"关闭") attributes:closeBtnAttrs];
[closeBtn setAttributedTitle: closeBtnStr];
[closeBtn setBordered:NO];
[closeBtn setTarget:self];
[closeBtn setAction:@selector(closeWnd:)];
- (void)closeWnd:(id)sender {
NSLog(@"close!!!");
window.isVisible = NO;
}
网友评论