I am assigning a button and an image to the same position (0, 0), but they are drawn in different locations. Why does this happen?
Here is my code:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
[window makeKeyWindow];
[window setFrame:NSMakeRect(0, 0, 500, 468) display:YES];
//[window setFrame:[[NSScreen mainScreen]frame] display:YES];
[window setBackgroundColor:[NSColor clearColor]];
[window center];
[[window contentView] setAutoresizesSubviews:YES];
NSImageView *subView = [[NSImageView alloc]initWithFrame:NSMakeRect(0, 0, 500, 468)];
[subView setImage:[NSImage imageNamed:@"Flowers.jpg"]];
[subView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[subView setAutoresizesSubviews:YES];
NSButton *subButton = [[NSButton alloc]initWithFrame:NSMakeRect(0, 0, 100, 40)];
[subButton setTitle:@"testing"];
[subButton setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable|NSViewMaxXMargin|NSViewMaxYMargin|NSViewMinXMargin|NSViewMinYMargin];
[subView addSubview:subButton];
[window setContentView:subView];
}
and here is the result after building: