![这里写图片描述](https://img-blog.csdn.net/20151212095339955)
@interface ViewController ()
@property(nonatomic,retain)UIImageView *myImageView;
@property(nonatomic,assign)BOOL isDid;
@end
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"点击" style:UIBarButtonItemStylePlain target:self action:@selector(Action)];
self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(250, 0, 120, 125)];
self.myImageView.backgroundColor = [UIColor grayColor];
[self.view addSubview:self.myImageView];
MenuButton *firstButton = [[MenuButton alloc]initWithFrame:CGRectMake(0, 0, 120, 40)];
firstButton.backgroundColor = [UIColor blackColor];
[firstButton addTarget:self action:@selector(firstAction) forControlEvents:UIControlEventTouchUpInside];
[self.myImageView addSubview:firstButton];
MenuButton *secondButton = [[MenuButton alloc]initWithFrame:CGRectMake(0, 40, 120, 40)];
secondButton.backgroundColor = [UIColor redColor];
[secondButton addTarget:self action:@selector(secondAction) forControlEvents:UIControlEventTouchUpInside];
[self.myImageView addSubview:secondButton];
MenuButton *thirdButton = [[MenuButton alloc]initWithFrame:CGRectMake(0, 80, 120, 40)];
thirdButton.backgroundColor = [UIColor yellowColor];
[thirdButton addTarget:self action:@selector(thirdAction) forControlEvents:UIControlEventTouchUpInside];
[self.myImageView addSubview:thirdButton];
self.myImageView.userInteractionEnabled = YES;
self.myImageView.hidden = YES;
self.isDid = YES;
}
- (void)Action{
if (self.isDid == NO) {
self.myImageView.hidden = YES;
}else{
self.myImageView.hidden = NO;
}
self.isDid = !self.isDid;
}
- (void)firstAction{
NSLog(@"1");
}
- (void)secondAction{
NSLog(@"2");
}
- (void)thirdAction{
NSLog(@"3");
}