2
我在NSScrollView內有一個NSTextView。滾動視圖具有用於高度和寬度的自動調整大小掩碼,所以它隨着它所在的窗口而改變大小。NSTextView背景沒有適當調整
文本視圖以蘋果文檔推薦here的方式設置很多。
但無論我把什麼設置放在文本視圖上,我都無法獲得背景顏色以隨滾動視圖一起調整大小。
這裏是我處理的圖片:
寬度的作品,而不是高度。
下面是TextView的我的設置代碼,因爲它是這樣的畫面:
NSTextView *view = [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, scrollview.contentSize.width, scrollview.contentSize.height) textContainer:textContainer];
[view setMinSize:NSMakeSize(0.0, scrollview.contentSize.height)];
[view setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
[view setVerticallyResizable:YES];
[view setHorizontallyResizable:NO];
[view setAllowsDocumentBackgroundColorChange:YES];
[view setDrawsBackground:YES];
[view setAutomaticLinkDetectionEnabled:YES];
[view setAutoresizingMask:NSViewWidthSizable];