1

如何在 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;
    }
4

1 回答 1

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;
    }
于 2011-06-04T21:08:24.893 回答