//创建一个button,添加在控制器视图
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
addButton.backgroundColor = [UIColor clearColor];addButton.frame = CGRectMake(0, 440, 40, 40);
[addButton addTarget:self action:@selector(add:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:addButton];
//创建一个视图,视图上可以放置其他button,从而达到节省空间的效果.其中.aView为uiview类的属性.
self.aView = [[UIView alloc] initWithFrame:CGRectMake(40, 420, 320, 60)];
self.aView.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.aView];
self.aView.hidden = YES;
//触发的方法
实现机理为循环改变视图的隐藏性.
- (void)add:(UIButton *)button
{
if (self.aView.hidden == NO) {
self.aView.hidden = YES;
}else{
self.aView.hidden = NO;
}
}