2016-10-20 129 views
0

實際上在操作系統中有一些不同的行爲
這是彈出窗口的樣子,因爲它在10.10中打開動畫:
enter image description here
如果你仔細觀察,你可以看到周圍的NSTextField帶有NSTextField的NSPopover顯示文本字段,它在打開時顯示不透明背景,然後在彈出動畫後變爲透明

這裏有點不透明的邊界是什麼樣子的10.11:
enter image description here 只是有一個直線上升不透明背景

而這裏的酥料餅的樣子動畫之後,盡顯:
enter image description here

修改酥料餅的外觀並沒有解決這個問題:
enter image description here

我們在這裏是一個NSViewController,它只有一個容器NSView和一個NSTextField。該容器是這樣我們就可以通過自動佈局約束

@interface MessageViewController() 
@property (strong) IBOutlet NSTextField *messageLabel; 
@property (weak) IBOutlet NSLayoutConstraint *rightPadding; 
@property (weak) IBOutlet NSLayoutConstraint *topPadding; 
@property (weak) IBOutlet NSLayoutConstraint *bottomPadding; 
@property (weak) IBOutlet NSLayoutConstraint *leftPadding; 
@end 

@implementation MessageViewController 

@synthesize message = _message; 

- (instancetype)initWithMessage:(NSString *)message andPadding:(CGFloat)padding 
{ 
    self = [super init]; 
    if(self) 
    { 
     [self loadView]; 
     self.rightPadding.constant = padding; 
     self.topPadding.constant = padding; 
     self.bottomPadding.constant = padding; 
     self.leftPadding.constant = padding; 
     self.message = message; 
    } 
    return self; 
} 

- (void)setMessage:(NSString *)message 
{ 
    _message = message; 
    self.messageLabel.stringValue = message; 
} 

- (NSString *)message 
{ 
    return _message; 
} 

這就是爲什麼你可以看到邊框,只有酥料餅的部分是不透明的添加填充。這是內部NSTextField有背景/邊框,容器視圖保持透明背景。它不是直到酥料餅盡顯的背景/邊框變爲透明以及

而且這裏是xib
enter image description here

怎麼會這樣?

我已經嘗試設置背景顏色屬性,並試圖設定-awakeFromNib,而不是在init屬性,但無濟於事

回答

0

解決了這個問題,在Interface Builder不得不檢查視圖和標籤「查看效果檢查器」,其集合wantsLayer = YES

也許可以通過編程方式完成