-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPictureBox.m
33 lines (28 loc) · 1009 Bytes
/
PictureBox.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <Cocoa/Cocoa.h>
@interface Window : NSWindow {
NSImageView* pictureBox1;
}
- (instancetype)init;
- (BOOL)windowShouldClose:(id)sender;
@end
@implementation Window
- (instancetype)init {
pictureBox1 = [[[NSImageView alloc] initWithFrame:NSMakeRect(10, 10, 280, 280)] autorelease];
[pictureBox1 setImage:[NSImage imageNamed:@"Logo.png"]];
[pictureBox1 setImageFrameStyle:(NSImageFrameGrayBezel)];
[super initWithContentRect:NSMakeRect(100, 100, 300, 300) styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
[self setTitle:@"PictureBox Example"];
[[self contentView] addSubview:pictureBox1];
[self setIsVisible:YES];
return self;
}
- (BOOL)windowShouldClose:(id)sender {
[NSApp terminate:sender];
return YES;
}
@end
int main(int argc, char* argv[]) {
[NSApplication sharedApplication];
[[[[Window alloc] init] autorelease] makeMainWindow];
[NSApp run];
}