如何在Cocoa中使用显示三角形调整额外的框?
- (IBAction)disclosureTriangleClicked:(id)sender {
NSWindow *window =[sender window];
NSRect frame = [window frame];
[otherBox frame].size.height +14;
switch([sender state]) {
case NSOnState:
[otherBox setHidden:NO];
//Must resize!
break;
case NSOffState:
[otherBox setHidden:YES];
//Must resize!
break;
default:
break;
}
答案 0 :(得分:2)
- (IBAction)disclosureTriangleClicked:(id)sender {
NSWindow *window =[sender window];
NSRect frameWinOld = [window frame];
CGFloat heightWinOld = frameWinOld.size.height;
NSRect frameOtherBox = [otherBox frame];
CGFloat heightOtherBoxWithMargin = frameOtherBox.size.height +14;
switch([sender state]) {
case NSOnState:
[window setFrame:NSRectMake(frameWinOld.origin.x, frameWinOld.origin.y, frameWinOld.width, frameWinOld.height + heightOtherBoxWithMargin) display:YES];
[otherBox setHidden:NO];
break;
case NSOffState:
[window setFrame:NSRectMake(frameWinOld.origin.x, frameWinOld.origin.y, frameWinOld.width, frameWinOld.height - heightOtherBoxWithMargin) display:YES];
[otherBox setHidden:YES];
break;
default:
break;
}