swift学习之路——uitabbar
来源:互联网 发布:mac怎么解压缩rar 编辑:程序博客网 时间:2024/05/16 08:50
class ViewController: UIViewController,UITabBarDelegate { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. var tabbar = UITabBar(frame: CGRectMake(0, self.view.bounds.height-55, self.view.bounds.width, 55)) var tabbaritema = UITabBarItem(title: "a", image: nil, tag: 1) var tabbaritemb = UITabBarItem(title: "b", image: nil, tag: 2) var tabbaritemc = UITabBarItem(title: "c", image: nil, tag: 3) var tabbaritemd = UITabBarItem(title: "d", image: nil, tag: 4) var tabbariteme = UITabBarItem(title: "e", image: nil, tag: 5) var items = NSArray(objects:tabbaritema,tabbaritemb,tabbaritemc,tabbaritemd,tabbariteme) tabbar.items = items tabbar.delegate = self tabbar.selectedItem = tabbaritemd tabbar.tintColor = UIColor.purpleColor() tabbar.barTintColor = UIColor.orangeColor() tabbar.itemPositioning = UITabBarItemPositioning.Centered self.view.addSubview(tabbar) } func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!){ <p class="p1"><span class="s1"> </span><span class="s2">if</span><span class="s1"> (item.</span><span class="s3">tag</span><span class="s1"> == </span><span class="s4">1</span><span class="s1">){</span></p><p class="p2"><span class="s1"> </span></p><p class="p2"><span class="s1"> </span></p><p class="p1"><span class="s1"> </span><span class="s5">println</span><span class="s1">(</span><span class="s6">"kok"</span><span class="s1">)</span></p><p class="p2"><span class="s1"> </span></p><p class="p2"><span class="s1"> </span></p><p class="p1"><span class="s1"> }</span><span class="s2">else</span><span class="s1">{</span></p><p class="p2"><span class="s1"> </span></p><p class="p2"><span class="s1"> </span></p><p class="p1"><span class="s1"> </span><span class="s5">println</span><span class="s1">(</span><span class="s6">"</span><span class="s1">\(item)</span><span class="s6">"</span><span class="s1">)</span></p><p class="p2"><span class="s1"> </span></p><p class="p1"><span class="s1"> }</span></p> }通过item 的tag值区分 item
0 0
- swift学习之路——uitabbar
- UITabBar的学习——TabbedApplication
- swift学习之路——UIDatePicker
- swift学习之路——Uislider
- swift学习之路——uiimageview
- Swift--自定义UITabBar
- Swift自定义UITabBar
- Swift 学习之路
- Snail—Swift基础学习之初识
- Snail—Swift基础学习之函数
- swift学习之路-数组
- 开始swift学习之路
- 开始swift学习之路
- 【swift】swift学习之旅!
- 【IOS 开发学习总结-OC-58】★UI控件——UITabBar 与UITabBarController
- iOS开发基础学习笔记——标签栏(UITabBar)
- swift 字符串——swift 学习(一)
- swift optional——swift学习(二)
- MFC中定义全局变量和全局函数的方法
- 轻松上云,从容实施Office 365项目
- ListView中分割线问题
- Windows7 程序无响应且无法关闭的解决方法
- Thinkphp Smarty 完美搭建WebApplication
- swift学习之路——uitabbar
- 脚本与编程语言的区别
- 使用IIS组建PHP服务器
- 黑马程序员---------Java面向对象——IO
- unstructured data
- 习题1.19
- HDU 5029 树链剖分
- 斐波那契(Fibonacci)数列 的实现
- html语言用重叠的方式做可输入的下拉框