UINavigationController

导航控制器nav.modalPresentationStyle UIModalPresentationFormSheet;//   modal adj. 模式的;情态的;形式的

self.hidesBottomBarWhenPushed  = YES;

self.navigationController.navigationBarHidden=NO;

 

// 3.设置导航栏的背景图片]

 [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"top_navigation_background.png"forBarMetrics:UIBarMetricsDefault];

导航栏的titleView上面可以放UIView,在UIView上面可以放UIImageView;导航栏的titleView上面也可以放UILable。记住,2个都要加到titleView的子图上。

// 设置状态栏为原来的黑色


 [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

设置leftBarButtonItem左对齐,rightBarButtonItem右对齐


初始化一个用于控制间距的UIBarButtonItem实例negativeSpacer,并设置negativeSpacer的width属性的值,设为-5的时候,正好可以使按钮与屏幕边界值为0,以rightBarButtonItem情况为例

    • UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];  
    • /**  
    • *  设置frame只能控制按钮的大小  
    • */  
    • btn.frame= CGRectMake(0, 0, 40, 44);  
    • [btn addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];  
    • UIBarButtonItem *btn_right = [[UIBarButtonItem alloc] initWithCustomView:btn];  
    • UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]   
    •                                   initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace   
    •                                   target:nil action:nil];  
    • /**  
    • *  width为负数时,相当于btn向右移动width数值个像素,由于按钮本身和边界间距为5pix,所以width设为-5时,间距正好调整  
    • *  为0;width为正数时,正好相反,相当于往左移动width数值个像素  
    • */  
    • negativeSpacer.width = -5;   
    • self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, btn_right, nil];  

判断self.navigationController == nil,假如这个成立  那么你是present过来的  假如这个不成立  也就是说self.navigationController不等于空  那么你是Push过来的

原文地址:https://www.cnblogs.com/dengchaojie/p/4743333.html