@interface aaa : UIView
- (IBAction)click;
@property(nonatomic,copy)void (^PushBlock)();
+(instancetype)header;
#import <QuartzCore/QuartzCore.h>
@implementation aaa
- (IBAction)click {
if (_PushBlock) {
_PushBlock();
}
}
+(instancetype)header
{
return [[NSBundle mainBundle]loadNibNamed:@"aaa" owner:nil options:nil][0];
}
#import "ViewController.h"
#import "aaa.h"
#import "FirstViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIView *view=[[UIView alloc]initWithFrame:[UIScreen mainScreen].applicationFrame];
// view.backgroundColor=[UIColor whiteColor];
[self.view addSubview:view];
aaa *a=[aaa header];
a.frame=CGRectMake(500, 500, 200, 200);
[self.view addSubview:a];
FirstViewController *first=[[FirstViewController alloc]init];
a.PushBlock=^{
[self.navigationController pushViewController:first animated:YES];
};
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}