view1.h 文件
@property(nonatomic,strong) NSView *aboutView;
在 view1.m 文件中创建了NSView
aboutView = [[NSView alloc]initWithFrame:NSMakeRect(6, 6, width -12, height -29)];
[aboutView setHidden:YES];
[view addSubview:aboutView];
NSImageView *imgl=[[NSImageView alloc]initWithFrame:NSMakeRect(0, 0, width -12, height -29)];
[imgl setImageAlignment:NSImageAlignBottomLeft];
[imgl setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[imgl setImageScaling:NSImageScaleAxesIndependently];
[imgl setImage:[NSImage imageNamed:@"yuan"]];
[aboutView addSubview:imgl];
ButtonController.m 中的NSView如何查找和隐藏NSView?
-(void)mouseUp:(NSEvent *)theEvent{
NSView *aboutView = [(view1 *)self.superview.window aboutView];
[aboutView setHidden:NO];
}
答案 0 :(得分:1)
怎么样
-(void)mouseUp:(NSEvent *)theEvent{
view1 *viewObj=(view1 *)self.superview.window;
NSView *aboutView = [viewObj aboutView];
[aboutView setHidden:YES];
}