如何编写一个运行在编写网游服务端模拟器的程序,定时统计数据库

IOS设置NavigationBar的颜色以及透明度
有时候我们需要设置UINavigationController的导航条NavigationBar的颜色为透明度,这时候就需要使用到NavigationBar的barStyle这个属性: 再看QQ空间的仿制项目示例: 代码使用示例:nc.navigationBa
有时候我们需要设置UINavigationController的导航条NavigationBar的颜色为透明度,这时候就需要使用到NavigationBar的barStyle这个属性:
      
再看QQ空间的仿制项目示例:
               
代码使用示例:nc.navigationBar.barStyle = UIBarStyleD
&备注:下面全部展示的UI图例,window.view背景是绿色的&
一、在没有设置背景图片的情况下:
1、UIBarStyleDefaul
因为是默认,所以可以不设置barStyle这个属性。
2、UIBarStyleBlack
3、UIBarStyleBlackOpaque
4、UIBarStyleBlackTranslucent(Translucent半透明)
&这里2~4都是一样的:
二、将1X1的透明图片或者是空UIImage对象(建议直接使用UIImage对象,连图片都不需要了),设置为背景
  代码实例:
  当然,还有一个前提需要提出来:一下实例图都是没有添加下面字段的(XCode 7.2.1版本)
1、UIBarStyleDefaul
2、UIBarStyleBlack
3、UIBarStyleBlackOpaque
4、UIBarStyleBlackTranslucent(Translucent半透明)
&这里2~4都是一样的:
三、将1X1的全黑色的图片,设置为背景
1、UIBarStyleDefaul
2、UIBarStyleBlack
3、UIBarStyleBlackOpaque
4、UIBarStyleBlackTranslucent(Translucent半透明)
&这里2~4都是一样的:
四、将1X1的红色的图片,设置为背景
1、UIBarStyleDefaul
2、UIBarStyleBlack
3、UIBarStyleBlackOpaque
4、UIBarStyleBlackTranslucent(Translucent半透明)
&这里2~4都是一样的:
附:遇到的还没有解决的问题:
  因为我看到QQ空间的导航控制器和状态栏是能够连在一起同时会渐变颜色,所以就讲上面通过图片设置背景换成直接更改导航条UINavigationBar的背景颜色试了试;
  我就添加了一行代码:
  效果却是这样的:
  然后我试了试默认不设置背景UIImage对象或者是不设置背景透明的图片:
  效果更加不好看了:
解决思路:
  我不知道QQ空间是怎么做到的,但是我下面会给出三种思路,其中两种思路会有具体实现。如果有哪位大神有更好的想法,欢迎交流,切磋切磋。
  这里展示一个出问题的效果,下面就针对这个情况进行解决问题:
思路1、自定义一个UINavigationBar,替换调用原来的自带的UINavigationBar。
  这个是可以实现的,但是我没有去实践,我就偷懒啦(责任编辑:最模板)
------分隔线----------------------------
在IOS开发中经常遇到倒计时倒计时问题,写一个Button,然后各种...
项目经过需求的变更,产品本身的迭代,会经过多次的改版,有...
本文主要是针对UIScrollView利用Masonry框架来自动布局,因为UIScr...
UIKit提供了一组控件:UISwitch开关、UIButton按钮、UISegmentedControl分...
在分析问题之前,我们先区分两个概念:进程和线程 进程:一个...
CopyRight (C)
最模板 , 深圳奇好科技有限公司 All Rights Reserved.Navigation bar 的注意事项-爱编程
Navigation bar 的注意事项
Bar button item 使用 button 作为 custom view,初始化 isEnabled 为 false,注意顺序
需要设置 bar button item 的 custom view 为 button,但一开始 isEnabled 要为 false。
生成一个 button
let leftButton = UIButton(frame: CGRect(x: 0, y: 0, width: 80, height: 44))
leftButton.setTitleColor(UIColor.green, for: .normal)
leftButton.setTitleColor(UIColor.red, for: .disabled)
leftButton.setTitle("Enabled", for: .normal)
leftButton.setTitle("Disabled", for: .disabled)
leftButton.addTarget(self, action: #selector(leftButtonClicked(_:)), for: .touchUpInside)
如果先设置 isEnabled,后设置 bar button item
leftButton.isEnabled = false
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftButton)
结果 isEnabled 还是 true
正确的顺序
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftButton)
leftButton.isEnabled = false // or navigationItem.leftBarButtonItem?.isEnabled = false
结果 isEnabled 是 false
放置两个 label。其中, frameLabel 没有添加约束(NSLayoutConstraint),constraintLabel 左、右、下都有约束,与 view 相接。
设置右上角按钮动作
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Change", style: .plain, target: self, action: #selector(rightButtonClicked(_:)))
改变 navigation bar isTranslucent 属性,显示 label 的坐标
@objc private func rightButtonClicked(_ sender: AnyObject) {
navigationController?.navigationBar.isTranslucent = !navigationController!.navigationBar.isTranslucent
updateLabelContent()
private func updateLabelContent() {
title = navigationController!.navigationBar.isTranslucent ? "Translecent" : "Opaque"
let frameLabelOrigin = frameLabel.frame.origin
frameLabel.text = "Frame label. x = \(frameLabelOrigin.x), y = \(frameLabelOrigin.y)"
let constraintLabelOrigin = constraintLabel.frame.origin
constraintLabel.text = "Constraint label. x = \(constraintLabelOrigin.x), y = \(constraintLabelOrigin.y)"
print("\(title)")
print("Status bar frame:", UIApplication.shared.statusBarFrame) // (0.0, 0.0, 375.0, 20.0)
print("Navigation bar frame:", navigationController!.navigationBar.frame) // (0.0, 20.0, 375.0, 44.0)
通过点击右上角按钮,来查看变化。
View controller 的 view 坐标改变,Status bar 和 navigation bar 的坐标不变
Navigation bar 从不透明变透明,status bar 和 navigation bar 的坐标都不变。整个 view 下移64,高度减小64,不会超出 window。没加约束的 frameLabel 坐标不变,但相对 window 的位置随着 view 一起下移。添加约束的 constraintLabel 的坐标改变,但是相对 window 的位置不变。
如果需要改变 navigation bar isTranslucent 属性,就要考虑对其他 view 会不会有影响,是否使用约束来定位。
版权所有 爱编程 (C) Copyright 2012. . All Rights Reserved.
闽ICP备号-3
微信扫一扫关注爱编程,每天为您推送一篇经典技术文章。ios7怎么设置navigationbar为完全透明的呢?
我在viewController中有一个全屏的image。想要达到的效果就是navigationbar为完全透明的,这样navigationbar后边的image也能显示出来。
我设置了navigationbar的translucent为YES。此时navigationbar为半透明的效果。
然后在appdelegate中设置了[[UINavigationBar appearance] setBarTintColor:[UIColor clearColor]];
但是此时navigationbar并不是全透明的,而是灰色的。
请教各位大神有什么好的办法吗?
猜你喜欢:
),然后在出现的“enter code here”处贴入你的代码。
回复特定回复的时候,请点击该回复右侧的回复链接,系统将自动创建楼号和@通知。
@他人的时候注意,id后面请加一个空格。
使用左侧工具栏“贴链接”按钮()创建的优酷、土豆、youtube视频链接,将自动生成播放区域,不需要使用其他包含方式。
如果要创作长篇格式复杂的帖子,本站建议Mac用户使用,离线写好,贴入即可。

我要回帖

更多关于 java编写http服务端 的文章

 

随机推荐