How to do collapse and expand view in mac applicat

2019-06-01 19:04发布

I am new to mac application development, here i want to do expand and collapse view in my custom view(NSView)

here the sample image

enter image description here

How can i achieve these kind of collapse and expand cell in NSViewController not in NSWindow...

Is it possible using NSTableView?

I know its a simple question but i facing problem.

Please suggest me some sample code or links..

Thanks

2条回答
We Are One
2楼-- · 2019-06-01 19:23

Collapsing / expanding can be implemented by adjusting auto layout constraints in the action method of the disclosure triangle button.

@property (nonatomic, weak) IBOutlet NSLayoutConstraint *moreInfoBoxHeight;

[[self.moreInfoBoxHeight animator] setConstant:75];

Apple has sample code using NSStackView at https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html

查看更多
我想做一个坏孩纸
3楼-- · 2019-06-01 19:43

The view at the picture given is NSOutlineView. It is the NSTableView subclass.

Look at the Apple reference page and Outline programming topics.

查看更多
登录 后发表回答