//以下四个条件缺一不可

/.必须是半透明状态
self.navigationBar.translucent = YES;
//2.导航栏背景图片为空图片 (不可以设置backgroundColor或者barTintColor, 没有效果的)
[self.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics: UIBarMetricsDefault];
//3.阴影图片为空图片 (不可以设置为nil,没用的)
[self.navigationBar setShadowImage:[[UIImage alloc] init]]; //其实到导航栏才44px, 但是backgroundView有64px
self.navigationBar.layer.masksToBounds = YES;

导航除线

self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.shadowImage = [UIImage new];
UIImage *img = [UIImage imageWithColor:[UIColor greenColor] size:CGSizeMake(, )];
//必须设置一张图片而不是设置背景颜色
[self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];

3.设置设置titleView时, titleView的宽度和高度无法自由设置

设置搜索案例

如果已经设置了默认返回的图标, 你会发现设置titleview时, 你的titleview左边会空出一块

UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(, , , )];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:tf];
self.navigationItem.leftBarButtonItem = item;

导航栏的坑 (导航透明/导航除线/titleIView)的更多相关文章

  1. 通过HTML+CSS+JavaScript实现鼠标移动到页面顶部导航栏出现,如果移出导航栏3秒又隐藏起来,而且不受滚动条影响(二)

    通过HTML+CSS+JavaScript实现鼠标移动到页面顶部导航栏出现,如果移出导航栏3秒又隐藏起来,而且不受滚动条影响(二) 效果:默认一直隐藏导航栏,当滚动条滚到超过300px按钮出现,点击回 ...

  2. Flutter沉浸式状态栏/AppBar导航栏/仿咸鱼底部凸起导航

    Flutter中如何实现沉浸式透明Statusbar状态栏效果? 如下图:状态栏是指android手机顶部显示手机状态信息的位置.android 自4.4开始新加入透明状态栏功能,状态栏可以自定义颜色 ...

  3. iOS 设置导航栏之二(设置导航栏的颜色、文字的颜色、左边按钮的文字及颜色)

                      #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicati ...

  4. iOS:导航栏的工具条和导航条

    功能:用NAV视图控制器打开新的视图,默认工具条和导航条隐藏,双击显示之 // // main.m // Hello // // Created by lishujun on 14-8-28. // ...

  5. jquery导航栏html页面跳转导航字体变色

    html代码: <div class="collapse"> <ul class="nav"> <li><a href ...

  6. Android 4.4 上实现透明导航栏和状态栏 Translucent system bar

    Translucent system UI styling To get the most impact out of your content, you can now use new window ...

  7. iOS frame从导航栏下面开始

    iOS7.0 之后,页面布局默认延伸到了手机界面的边缘;导航栏背景成透明颜色. 解决fram从导航栏下面开始方法: 第一种: 将导航栏改成不透明即可 if( ([[[UIDevice currentD ...

  8. App开发流程之状态栏和导航栏

    记录状态栏和导航栏的设置和控制,统一在基类视图控制器中完成. 状态栏. 状态栏高度为20,iOS7以后背景完全透明. 样式枚举如下: typedef NS_ENUM(NSInteger, UIStat ...

  9. 【Swift】iOS导航栏错乱的原因

    #iOS开发高级技巧#导航栏错乱,也就是导航栏的显示效果与内容区不匹配,引发原因很多,其中最重要的有两个原因: 1.在viewwillappear,viewwilldisappear两个函数中,设置导 ...

随机推荐

  1. edmx代码分析

    http://www.cnblogs.com/FoundationSoft/archive/2011/01/08/1930479.html 本文分析Entity Framework从数据库自动生成的模 ...

  2. 安装beautifulsoup4

    python scripts下 pip install beautifulsoup4

  3. re正则表达式13_review of regex symbols

    Review of Regex Symbols This chapter covered a lot of notation, so here’s a quick review of what you ...

  4. [问题] UISearchBar 点击取消后跳动的问题

    问题详情: 首先是TableView 作为 NavigationController 的 RootViewContrller, 然后UISearchBar   添加到TableView 的 headV ...

  5. Java多线程编程核心技术--Lock的使用(一)

    使用ReentrantLock类 在Java多线程中,可以使用synchronized关键字来实现线程之间的同步互斥,但在JDK1.5中新增加了ReentrantLock类也能达到同样的效果,并且在扩 ...

  6. php概率算法(转)

    这是一个很经典的概率算法函数: function get_rand($proArr) { $result = ''; //概率数组的总概率精度 $proSum = array_sum($proArr) ...

  7. ASP.NET中最保险最环保的返回404的方法

    代码如下: Response.StatusCode = 404; Response.SuppressContent = true; Context.ApplicationInstance.Comple ...

  8. wamp包--如何导出sql

    在windows下安装wamp,如果不想用phpmyadmin工具和其他工具,如何导出自己想要的sql呢. 比如:我想导出blogyaf库,可以从以下步骤进行操作. 1,进入到wamp的mysql安装 ...

  9. What is the most common software of data mining? (整理中)

    What is the most common software of data mining? 1 Orange? 2 Weka? 3 Apache mahout? 4 Rapidminer? 5 ...

  10. hdu4951 Multiplication table (乘法表的奥秘)

    http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...