奇怪的事情
步骤
结果[NG]
预期结果
以下示例非常简单
ViewController类
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"%s : %f", __func__, self.navigationController.navigationBar.alpha);
}
- (void)viewDidAppear:(BOOL)animated {
NSLog(@"%s : %f", __func__, self.navigationController.navigationBar.alpha);
}
- (void)viewWillDisappear:(BOOL)animated {
NSLog(@"%s : %f", __func__, self.navigationController.navigationBar.alpha);
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.backgroundColor = [UIColor orangeColor];
self.view.backgroundColor = [UIColor whiteColor];
UIButton *clickMe = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 30)];
[clickMe setTitle:@"clickme" forState:UIControlStateNormal];
[clickMe setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[clickMe addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:clickMe];
}
- (void)btnClicked {
self.navigationController.navigationBar.alpha = 0.0f;
second *sec = [[second alloc] init];
[self presentViewController:sec animated:YES completion:nil];
}
第二课
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.navigationController.navigationBar.backgroundColor = [UIColor orangeColor];
self.view.backgroundColor = [UIColor yellowColor];
UIButton *getBack = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 40)];
[getBack setTitle:@"getBack" forState:UIControlStateNormal];
[getBack setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[getBack addTarget:self action:@selector(btnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:getBack];
}
- (void)btnClicked {
[self dismissViewControllerAnimated:YES completion:nil];
}
我真的很想知道这件事发生了什么.. 如果有人知道这一点,请告诉我..提前谢谢你。