NSButton

作者: 皮蛋豆腐酱油 | 来源:发表于2019-10-17 15:02 被阅读0次
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;
}

相关文章

网友评论

      本文标题:NSButton

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