`
niCe
  • 浏览: 42195 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

UINavigationBar + UISegmentedControl

 
阅读更多
//navigationBar通常只有左、右两个按钮,但可以
//通过添加UISegmentedControl来增加控制按钮
UINavigationBar* _navBar;
UISegmentedControl* _SegCtl; 
 
_navBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 40.0f)];
[_navBar showButtonsWithLeftTitle: @"Done" rightTitle:NULL leftBack: TRUE];
[_navBar setBarStyle: 3];
[_navBar enableAnimation];
[_navBar setDelegate: self];
 
_SegCtl = [[UISegmentedControl alloc] initWithFrame:CGRectMake(80.0f, 8.0f, 230.0f, 30.0f) withStyle:2 withItems:NULL];
[_SegCtl insertSegment:0 withTitle:@"Button one" animated:FALSE];
[_SegCtl insertSegment:1 withTitle:@"Button two" animated:FALSE];
[_SegCtl insertSegment:2 withTitle:@"Button three" animated:FALSE];
[_SegCtl setDelegate:self];
[_navBar addSubview:_SegCtl];
NSLog(@"navigation items is: %@", [_navBar navigationItems]);

 

分享到:
评论

相关推荐

    swift-iOS仿照今日头条滚动列表

    总之,仿照“今日头条”滚动列表的实现涉及Swift UI编程中的多个方面,包括UIScrollView、UILabel、UINavigationBar和UISegmentedControl的使用,以及事件监听和性能优化。通过深入学习和实践,你将能够创建出具有...

    (0013)-iOS/iPhone/iPAD/iPod源代码-导航条(Navigation Bar)-NavBar

    在本资源"(0013)-iOS/iPhone/iPAD/iPod源代码-导航条(Navigation Bar)-NavBar"中,重点讲述了如何自定义UINavigationBar以及在其中添加各种元素,如按钮和Segments等。 首先,UINavigationBar是UIKit框架中...

    自定义导航条的按钮效果

    将`UISegmentedControl`添加到`UINavigationBar`上,可以为用户提供多选项操作,比如切换视图或过滤内容。 3. **中间内容**:默认情况下,`UINavigationBar`中间显示的是`UINavigationItem.title`,但开发者也可以...

    Swift实现的常用iOS UI控件

    包含常用的控件的使用UILabel、UIButton、UIsegmentedControl、UITextField、UISlider、UISwitch、UIActivityIndicatorView、UIProgressView、UIStepper、UIImageView、UIAlertView、UIActionSheep、UIDatePicker、...

    Swift — UIKit 之(1)—— 基本组件总览

    导航栏(UINavigationBar)9. 标签栏(UITabBarController)10. 按钮(UIButton)11. 分段控件(UISegmentedControl)12. 文本字段(UITextField)13. 滑块(UISilder)14. 开关(UISwitch)15. 日期选

    ios-dev-resources:IOS应用开发的知识和资源

    -- 按钮 -- 滑块 -- 切换 -- 日期选择 -- 分页 -- 下拉刷新UISegmentedControl -- 类似PC端的tabbarUIStepper -- 增减器UITextField -- 文本输入框UIAccessibilityElement -- 让 APP 支持无障碍...

    CustomzingUINavigationBar:自定义NavBar

    自定义UINavigationBar NavBar演示了如何将UINavigationController和UIViewController类一起用作应用程序用户界面的构建块。 开始开发新应用程序时,可以将其用作参考。 本示例中的各个页面展示了如何使用外观代理...

    NavigationController

    `NavigationController`还支持其他高级特性,如分段控制器(`UISegmentedControl`)在导航栏上的集成,以及通过`popToRootViewController(animated:)`或`popToViewController(_:animated:)`方法快速回到栈中的某个...

    模拟实现网易新闻标题栏

    由于标题栏的功能类似于导航栏,但又需要定制颜色变化和动态移动效果,我们可能需要自定义一个UINavigationBar的子类,覆盖其默认行为。这样可以在滑动时改变背景颜色,并实现标题栏随内容移动的效果。 3. **滑动...

    NSObject树-UI1

    `UINavigationBar`和`UINavigationBarAppearance`用于顶部导航栏的定制,`UIToolbarAppearance`和`UIBarAppearance`则分别用于工具栏和通用条目外观的定制。 `UIBarItem`和`UITabBarItem`是导航栏和标签栏上的按钮...

    自定义的导航视图

    1. **创建自定义导航栏视图**:你需要创建一个继承自`UINavigationBar`的子类,然后重写其`drawRect:`方法,以实现自定义的绘制逻辑。也可以使用`UIAppearance`协议,通过设置全局属性影响所有实例的外观。 2. **...

Global site tag (gtag.js) - Google Analytics