1. 首先创建一个MyView类,继承NSView,如下:
1
2
3
4
5
6
7
8
9
10
11
12
|
// // // // // // // #import @interface @end |
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
37
38
39
40
|
// // // // // // // #import @implementation - { self if
// } return
} - void )drawRect:(NSRect)dirtyRect { NSString "MyView ; //属性包装设置 NSMutableDictionary //设置字体样式 [dic "Times"
//设置字体颜色 [dic //绘制 [str } @end |
代码很easy理解,不在赘述啦~
下面我们看一些基础常用控件:
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
37
38
39
40
41
42
43
|
// // // // // // // #import #import @interface { IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet IBOutlet } -(IBAction)btnPress:(id)sender; @property @end |
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// // // // // // // #import @implementation @synthesize - void )applicationDidFinishLaunching:(NSNotification { //------绑定Delegate [tbView } -(IBAction)btnPress:(id)sender{ //------ if (btn [myView } //------处理NSPopUpButton if (popBtn NSLog(@ "%@" ,[popBtn NSLog(@ "%@" ,[popBtn NSLog(@ "%@" ,[popBtn } //------处理 if (nsc NSLog(@ "%i" ,[nsc NSLog(@ "%i" ,[nsc NSLog(@ "%i" ,[nsc } //------处理 if (nForm NSLog(@ "NSForm ,[[nForm NSLog(@ "NSForm ,[[nForm NSLog(@ "NSForm ,[[nForm } //------处理NSMatrix if (ms NSLog(@ "NSMatrix ,[[ms } //-----处理 if (nsp NSString "%i" , int )[nsp [nfCount } //-----处理 if (nsWell NSColor* NSLog(@ "R=%f,G=%f,B=%f" ,[color } } //------处理 //-(void)tabView:(NSTabView -( void )tabView:(NSTabView if
NSLog(@ "view ); } else
NSLog(@ "view ); } } @end |
运行截图如下: