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

[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
 
 
 
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 @   为敢技术  阅读(1002)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示
哥伦布
10:09发布
哥伦布
10:09发布
2°
西南风
2级
空气质量
相对湿度
68%
今天
2°/16°
周二
7°/19°
周三
多云
7°/19°