-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathLabel.m
36 lines (31 loc) · 1 KB
/
Label.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
34
35
36
#include <Cocoa/Cocoa.h>
@interface Window : NSWindow {
NSTextField* label1;
}
- (instancetype)init;
- (BOOL)windowShouldClose:(id)sender;
@end
@implementation Window
- (instancetype)init {
label1 = [[[NSTextField alloc] initWithFrame:NSMakeRect(10, 270, 100, 20)] autorelease];
[label1 setStringValue:@"label1"];
[label1 setBezeled:NO];
[label1 setDrawsBackground:NO];
[label1 setEditable:NO];
[label1 setSelectable:NO];
[super initWithContentRect:NSMakeRect(100, 100, 300, 300) styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
[self setTitle:@"Label Example"];
[[self contentView] addSubview:label1];
[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];
}