ios - 半透明导航栏移动部分标题

标签 ios objective-c xcode swift uinavigationbar

我只是一个努力获得半透明导航栏的简单人。 我尝试在 appDelegate 和特定的 ViewController 中设置它。 我最终得到的是这样的: 有谁知道为什么白色的部分标题向下移动?当我滚动时,导航栏甚至不是半透明的,而且我无法为其设置颜色。 (当半透明= false时我可以设置颜色) 我尝试将其设置为半透明和不透明,并在 Storyboard中推断。(不起作用)

更新:

let colorImage = imageFromColor(UIColor(red:0.22, green:0.23, blue:0.29, alpha:0.5), frame: CGRectMake(0, 0, 340, 64))
self.navigationController!.navigationBar.setBackgroundImage(colorImage, forBarMetrics: UIBarMetrics.Default)
self.navigationController!.navigationBar.shadowImage = colorImage
self.navigationController!.navigationBar.translucent = true

colorImage 是我用 rgb-uicolor 制作的图像。结果是这样的:navigation bar 2

节标题之间是半透明的,但顶部栏不是!

UPDATE 2

最佳答案

如果您尝试在应用程序中为 navigationBar 设置半透明背景,则可以在 AppDelegateapplication:didFinishLaunchingWithOptions 方法中使用以下代码

let colorImage = getImageWithColor(UIColor(red:0.22, green:0.23, blue:0.29, alpha:0.5), size: CGSizeMake(360, 64))
UINavigationBar.appearance().setBackgroundImage(colorImage, forBarMetrics: UIBarMetrics.Default)
UINavigationBar.appearance().translucent = true
UINavigationBar.appearance().tintColor = UIColor.whiteColor()

Result Screenshot:

enter image description here

关于ios - 半透明导航栏移动部分标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34054593/

相关文章:

ios - 在 UIPageViewController 上方画一条路径

ios - 带出队的 UICollectionView 查询

iphone - 检查设备iOS平台是否存在重载方法

iphone - 如何解决线程错误 EXC_BAD_ACCESS?

iphone - 检测用户是否按下 Go 或隐藏键盘按钮 UITextField

ios - 无法上传新版本的应用

ios - 使用 JustHTTP 和 Alamofire 发送两次 HTTP post

IOS 推送通知声音不来

objective-c - Uiimage 错误初始化和 EXC_BAD_ACCESS

objective-c - static const int 对于数组大小来说不够好?