简体   繁体   English

NSTextfield isBordered属性被重置

[英]NSTextfield isBordered property getting reset

I am using a nib/xib and want to identify if a particular NSTextfield has a border set. 我正在使用笔尖/ xib,想要确定特定的NSTextfield是否具有边框。

NSArray *objects = [NSArray array];

[[NSBundle mainBundle] loadNibNamed:nibName owner:nil topLevelObjects:&objects];
for (NSObject *obj in objects)
{
    if ( [obj isKindOfClass:[NSView class]] )
    {
        mainView = (NSView *)obj;
        break;
    }
}

for (NSView *view in [mainView subviews])
{
    if([view isKindOfClass:[NSTextField class]])
    {
        NSTextField *label = (NSTextField*)view;
        NSLog(@"view is bordered: %d", label.isBordered);
    }
}

The textfields are shown correctly bordered or not in IB, but when the above code runs, it always reports false for bordered regardless of whether it is bordered or not. 文本字段在IB中是否正确显示为带边框,但是运行上述代码时,无论带边框与否,它始终报告false。 I've tried using NSControl instead of NSView in the for loop, but this makes no difference. 我试过在for循环中使用NSControl而不是NSView,但这没什么区别。

How can I correctly identify the 'isBordered' state? 如何正确识别“ isBordered”状态? Thanks. 谢谢。

label.bezeled
label.bezelStyle

NSTextFieldSquareBezel  = 0,
NSTextFieldRoundedBezel = 1

UPDATE: NSTextField has 4 borderStyle 更新: NSTextField具有4 borderStyle

  1. isBordered = NO; isBordered = NO; isBezeled = YES; isBezeled =是; BezelStyle = 0; BezelStyle = 0;
  2. isBordered = NO; isBordered = NO; isBezeled = NO; isBezeled =否; BezelStyle = 0; BezelStyle = 0;
  3. isBordered = YES; isBordered = YES; isBezeled = NO; isBezeled =否; BezelStyle = 0; BezelStyle = 0;
  4. isBordered = NO; isBordered = NO; isBezeled = YES; isBezeled =是; BezelStyle = 1; BezelStyle = 1;

Information about this can be found here 可以在这里找到有关此信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM