社交类项目总结

创建程序的主架构

2015-12-25  本文已影响148人  iOS_Cqlee

Third Chapter

创建程序的主架构

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    

    // 如果不是第一个push进来的子控制器,需要设置返回键
    if (self.childViewControllers.count > 0 ){
        //要想一个控件显示注意要有尺寸,视情况而定还有颜色
        UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backBtn setTitle:@"返回" forState:UIControlStateNormal];
        [backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [backBtn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        [backBtn setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
        [backBtn setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];
        [backBtn sizeToFit];
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -15, 0, 0);
        [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
        //push进来的子控制器隐藏底部tabbar
        viewController.hidesBottomBarWhenPushed = YES;
        
    }
    
    //最好把这push放在这
    [super pushViewController:viewController animated:animated];
    
}



- (void)back{
    [self popViewControllerAnimated:YES];
}


上一篇 下一篇

猜你喜欢

热点阅读