iOS开发点滴

设置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];
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容