1、註冊PCH文件
commond + N —>other —> PCH File —> Build Settings搜索pref 把建好的pct拖到框中。
2、快捷設置變量名
3、
// 拿到UIView的Controller
- (UIViewController *)viewController {
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
[[self viewController] presentViewController:imagepicker animated:YES completion:nil];
4、
// 1 navigationItem的UIBarButtonItem的偏移
UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeSystem];
leftBtn.frame = CGRectMake(0, 0, 65, 26);
[leftBtn setImage:[UIImage imageNamed:@"fanhui_btn_normal.png"] forState:UIControlStateNormal];
[leftBtn setTitle:@"返回" forState:UIControlStateNormal];
leftBtn.titleLabel.font = [UIFont systemFontOfSize:17];
[leftBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[leftBtn addTarget:self action:@selector(checkAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
negativeSpacer.width = -18;
UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacer,leftButton, nil];
// 2
leftBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -16, 0, 0);
self.navigationItem.leftBarButtonItem = leftButton;
5、navigationBar的動畫
[self.navigationController setNavigationBarHidden:NO animated:NO];
self.navigationController.navigationBar.hidden = YES;
[self.navigationController setNavigationBarHidden:YES animated:YES];
待續中···