设置navigation titleView 居中
添加左边按钮后再添加titleView会导致titleView不居中,之前是直接用UIImageView直接赋值给titleView宽度默认为屏幕宽度除去左边按钮所以不居中。应该用UIView添加UIImageview再赋值给titleView。
UIView *vc = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
// vc.backgroundColor = RandomColor;
UIImageView *titleView = [[UIImageView alloc] init];
titleView.frame = vc.frame;
titleView.contentMode = UIViewContentModeScaleAspectFit;
[titleView setImage:[UIImage imageNamed:@"hos"]];
[vc addSubview:titleView];
self.navigationItem.titleView = vc;
获取父类的navigationController
[self.parentViewController.navigationController popViewControllerAnimated:YES];
设置tableView section间隔
- (CGFloat)tableView:(UITableView*)tableView
heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 6.0;
}
return 1.0;
}
- (CGFloat)tableView:(UITableView*)tableView
heightForFooterInSection:(NSInteger)section {
return 5.0;
}
- (UIView*)tableView:(UITableView*)tableView
viewForHeaderInSection:(NSInteger)section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
- (UIView*)tableView:(UITableView*)tableView
viewForFooterInSection:(NSInteger)section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
网友评论