4
A
回答
0
您需要中的插入文檔視圖中的內容,以便用於陰影來顯示,然後層背面的圖,並設置了一片陰影它。例如:
view.wantsLayer = YES;
NSShadow *shadow = [NSShadow new];
shadow.shadowColor = [NSColor blackColor]
shadow.shadowBlurRadius = 4.f;
shadow.shadowOffset = NSMakeSize(0.f, -5.f);
view.shadow = shadow;
0
的NSScrollView內容查看是一個的NSView子類,其中有一個影子字段,如果創建一個陰影對象並將其分配給該字段,該視圖將自動地縮回
NSShadow* shadow = [[NSShadow alloc] init];
shadow.shadowBlurRadius = 2; //set how many pixels the shadow has
shadow.shadowOffset = NSMakeSize(2, -2); //the distance from the view the shadow is dropped
shadow.shadowColor = [NSColor blackColor];
self.scrollView.contentView.shadow = shadow;
當顯示陰影
這是可行的,因爲所有視圖在drawRect上繪製時使用[shadow set]使用此陰影屬性。
平局操作過程中做[影子集]讓無論是繪製後,爲下
0
我是新來的堆棧溢出進入帖子被複制,但我有同樣的問題,並解決它,所以我想在網上搜索幾個小時以找到解決方案後,回答它會很好。
我的解決方案是創建一個NSClipView子與drawRect中下面的代碼...
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
NSRect childRect = [[self documentView] frame];
[NSGraphicsContext saveGraphicsState];
// Create the shadow below and to the right of the shape.
NSShadow* theShadow = [[NSShadow alloc] init];
[theShadow setShadowOffset:NSMakeSize(4.0, -4.0)];
[theShadow setShadowBlurRadius:3.0];
// Use a partially transparent color for shapes that overlap.
[theShadow setShadowColor:[[NSColor grayColor]
colorWithAlphaComponent:0.95f]];
[theShadow set];
[[self backgroundColor] setFill];
NSRectFill(childRect);
// Draw your custom content here. Anything you draw
// automatically has the shadow effect applied to it.
[NSGraphicsContext restoreGraphicsState];
}
然後你需要創建一個子類的實例,並與選擇的setContentView設置。
您還需要在每次內容視圖大小更改時重新繪製剪輯視圖。如果您的內容視圖設置爲根據用戶需要的畫布大小進行更改,則除非您重新繪製剪輯視圖,否則會留下一些令人厭惡的陰影標記。
你不需要像其他人所建議的那樣混淆剪輯。
希望它有幫助!
相關問題
- 1. NSScrollview DocumentView AutoresizingMask
- 2. NSScrollView的中心documentView在中心
- 3. 如何隱藏NSScrollView Scroller?
- 4. NSScrollView:它保留-documentView嗎?
- 5. 子類化NSScrollView的DocumentView
- 6. 滾動NSScrollView的documentView過去CGFloat範圍
- 7. 隱藏NSScrollView嵌入內容
- 8. 隱藏NSScrollView的滾動條
- 9. 爲什麼[[NSScrollView documentView] scrollPoint:]在loadView方法中不工作?
- 10. 如何設置NSScrollView不自動隱藏scorller?
- 11. 是否可以爲NSScrollView提供非常大的documentView?
- 12. 在NSScrollView中啓用滾動功能時隱藏滾動條
- 13. 自動隱藏NSScrollView中只有水平滾動條
- 14. 如何在nginx中隱藏#
- 15. 如何在隱藏「dd」後隱藏「dd」
- 16. 如何隱藏在
- 17. 當滾動條被隱藏時,NSScrollview和autohidescrollers會通知
- 18. 如何在greasemonkey中創建隱藏/取消隱藏按鈕
- 19. 如何在C#中隱藏/取消隱藏進程?
- 20. 如何在SQL中隱藏或隱藏重複值?
- 21. 如何使UITextField在IOS中隱藏/隱藏?
- 22. 如何在複選框中隱藏和取消隱藏框
- 23. 如何在WPF Ribbon控件中禁用隱藏/取消隱藏
- 24. 如何隱藏
- 25. 如何隱藏滾動(溢出:隱藏)?
- 26. 如何隱藏或UITableViewCell中
- 27. 如何隱藏[「java.util.LinkedList中」,[
- 28. 如何隱藏在HTML
- 29. 如何隱藏在iphone
- 30. 如何在代碼隱藏
你會考慮增加一些敘述來解釋爲什麼這段代碼有效嗎?是什麼使它成爲問題的答案?這對詢問問題的人以及任何其他人來說非常有幫助。 – 2013-03-11 18:00:10