为有牺牲多壮志,敢教日月换新天。

[Swift]枚举类型:UIBarButtonItem的24种样式

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公众号:山青咏芝(shanqingyongzhi)
➤博客园地址:山青咏芝(https://www.cnblogs.com/strengthen/ 
➤GitHub地址:https://github.com/strengthen/LeetCode
➤原文地址:https://www.cnblogs.com/strengthen/p/10675063.html 
➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

热烈欢迎,请直接点击!!!

进入博主App Store主页,下载使用各个作品!!!

注:博主将坚持每月上线一个新app!!!

UIBarButtonSystemItemFlexibleSpace
可变空白,
在调用的过程中,使用  UIBarButtonSystemItemFlexibleSpace去占位,达到实现规范化的目的
 
UIBarButtonSystemItemFixedSpace
不可变空白 
相应的 UIBarButtonSystemItemFixedSpace则是使特定位置控件替代.
 
UIBarButtonSystemItemDone
 
 
UIBarButtonSystemItemCancel
 
 
UIBarButtonSystemItemEdit
 
 
UIBarButtonSystemItemSave
 
 
UIBarButtonSystemItemAdd
 
 
 
UIBarButtonSystemItemCompose 
 
UIBarButtonSystemItemReply
 
 
UIBarButtonSystemItemAction
 
 
UIBarButtonSystemItemOrganize
 
 
UIBarButtonSystemItemBookmarks
 
 
UIBarButtonSystemItemSearch
 
 
UIBarButtonSystemItemRefresh
 
 
UIBarButtonSystemItemStop
 
 
UIBarButtonSystemItemCamera
 
 
UIBarButtonSystemItemTrash
 
 
UIBarButtonSystemItemPlay
 
 
UIBarButtonSystemItemPause
 
 
UIBarButtonSystemItemRewind
 
 
UIBarButtonSystemItemFastForward
 
 
UIBarButtonSystemItemUndo
 
 
UIBarButtonSystemItemRedo
 
 
UIBarButtonSystemItemPageCurl NS_ENUM_DEPRECATED_IOS(4_0, 11_0)

  • IBarButtonSystemItemFlexibleSpace 和 UIBarButtonSystemItemFixedSpace不是按钮,而是调整按钮间距用的对象.让多个按钮等间距地分布在工具条中
  • 在调用的过程中,使用 UIBarButtonSystemItemFlexibleSpace去占位,达到实现规范化的目的,效果如下:
  • 不使用UIBarButtonSystemItemFlexibleSpace


     
     
  • 使用UIBarButtonSystemItemFlexibleSpace


     
     
  • UIBarButtonSystemItemFixedSpace则是替代特定位置控件,效果:


     

示例代码:
 1  override func viewDidLoad() {
 2      super.viewDidLoad()
 3      // Do any additional setup after loading the view, typically from a nib.
 4      //Prompt 属性被设置以后,其高度变为74
 5      self.navigationItem.prompt = "顶端提示"
 6      //设置导航视图标题
 7      self.title = "导航视图标题"
 8      //设置当前视图控制器的背景颜色为白色
 9      self.view.backgroundColor = UIColor.white
10      //修改导航栏背景图片(使用代码动态生成的纯色图片)
11      let image = createImageWithColor(UIColor.white,frame: CGRect(x: 0, y: 0, width: 1, height: 1))
12      self.navigationController?.navigationBar.setBackgroundImage(image, for: .default)
13      //设置背景色为不透明
14      self.navigationController?.navigationBar.isTranslucent = false
15      //设置两侧按钮颜色
16      self.navigationController?.navigationBar.tintColor = UIColor.gray
17      //设置主题颜色为黑色透明
18      self.navigationController?.navigationBar.barStyle = UIBarStyle.blackTranslucent
19      //设置左侧文件夹按钮图标,并绑定按钮点击事件
20      self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .organize,
21                                           target: self,
22                                           action: #selector(openPhotoAlbum))
23      //设置右侧相机按钮图标,并绑定按钮点击事件
24      self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .camera,
25                                            target: self,
26                                            action: #selector(ScanQRCode))
27     }
28 
29 //打开系统相册
30 @objc func openPhotoAlbum() 
31 {
32     
33 }
34 
35 //打开相机
36 @objc func ScanQRCode()
37 {
38     
39 }

 



posted @ 2019-04-09 09:53  为敢技术  阅读(939)  评论(0编辑  收藏  举报