1.创建world工程项目
工程项目中会有
一、.头文件定义
ViewController.h和ViewController.m两个文件,其中.h文件为头文件,
.m文件为实现文件,从图中可以看出.h文件中定义了三个输出口变量及
三个实现方法,分别为
IBOutlet UIButton *leftButton;
IBOutlet UIButton *rightButton;
IBOutlet UIButton *centerButton;
-(IBAction) clickLeftButtton:(id)sender;
-(IBAction) clickRightButton:(id)sender;
-(IBAction) clickCenterButton:(id)sender;
二、头文件方法实现
@synthesize leftButton;
@synthesize rightButton;
@synthesize centerButton;
- (IBAction) clickLeftButtton:(id)sender
{
self.view.backgroundColor = [UIColor blueColor];
}
- (IBAction) clickRightButton:(id)sender
{
self.view.backgroundColor = [UIColor redColor];
}
- (IBAction) clickCenterButton:(id)sender
{
self.view.backgroundColor = [UIColor greenColor];
}
三、视图文件.xib将定义和实现的输出口及实现的方法跟UI的左、中、右三个按钮链接起来
就OK了,如下图所示,希望对入门级的初学者有所帮助