如何用可可創建自定義滾動條?用可可自定義Mac滾動條
4
A
回答
6
不要重新發明過多輪的,如果你不就得了。如果您只是想自定義滾動條的外觀,只需要將NSScroller子類化並覆蓋各種draw
方法可能更容易。
這是未經測試的代碼,但它應該證明如果您有自己的圖像MyKnob.png
,您需要做些什麼來定製旋鈕的外觀。
@interface MyScroller : NSScroller
{
NSImage *knobImage;
}
@end
@implementation MyScroller
- (void) dealloc
{
[knobImage release];
[super dealloc];
}
- (id) initWithFrame:(NSRect) frame
{
self = [super initWithFrame:frame];
if (!self) return nil;
knobImage = [[NSImage imageNamed:@"MyKnob.png"] retain];
return self;
}
- (void) drawKnob
{
// Work out where exactly to draw the knob
NSPoint p = NSMakePoint(0.0, 0.0);
[knobImage drawAtPoint:p fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
@end
0
一個好的開始是看看Aaron Hillegass的這篇文章。 link text
達里爾
1
奇妙的BWToolkit http://www.brandonwalkin.com/bwtoolkit/有不同的外觀的滾動視圖的自己的實現。源代碼會告訴你它是如何完成的。
相關問題
- 1. C#:可滾動面板上的自定義滾動條滾動條
- 2. 可可:在應用程序啓動時隱藏textview的自定義滾動條
- 3. DATATABLES自定義滾動條
- 4. 自定義jQuery滾動條
- 5. 自定義滾動條iOS
- 6. 使滾動條自定義
- 7. FlowLayoutPanel。自定義滾動條
- 8. 自定義Jtable滾動條
- 9. 自定義滾動條
- 10. 自定義滾動條
- 11. Select2 +自定義滾動條
- 12. UITableView自定義滾動條
- 13. Emacs滾動條自定義
- 14. 自定義滾動條
- 15. Flash自定義滾動條
- 16. 自定義滾動條
- 17. Javascript自定義滾動條
- 18. 自定義滾動條
- 19. 自定義滾動條
- 20. 自定義iframe滾動條
- 21. 自定義webview滾動條
- 22. jQuery自定義滾動條
- 23. 自定義滾動條
- 24. Swing - 自定義滾動條
- 25. 自定義滾動條
- 26. 用自定義滾動條替換面板滾動條
- 27. 自定義邊框Windows窗體和滾動條可見性
- 28. 如何使jScrollPane自定義滾動條始終可見?
- 29. 自定義jScrollPane滾動條可能被拖得太低
- 30. Textarea和自定義滾動條 - jQuery自定義內容滾動條
FWIW,命名的圖像永遠不會消失。 NSImage將它們保存在全局池中。儘管如此,保留並沒有傷害任何東西。 – NSResponder 2009-12-29 06:02:51