NSButton

2019-10-17  本文已影响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;
}
上一篇 下一篇

猜你喜欢

热点阅读