UINavigationController技巧<三>:在navigationBar上添加控件

一、添加系统自带的控件

①按钮效果有三种style可选

UIBarButtonItemStyleBordered
UIBarButtonItemStyleDone
UIBarButtonItemStylePlain
UIBarButtonItem *borderedBar  = [[UIBarButtonItem alloc] initWithTitle:@"borderedBar" style:UIBarButtonItemStyleBordered target:self action:@selector(action)];
    self.navigationItem.rightBarButtonItem = borderedBar;

添加方法如上,效果分别如下三个图:

②带图片效果Identifier有以下类型

UIBarButtonSystemItemDone,
    UIBarButtonSystemItemCancel,
    UIBarButtonSystemItemEdit,  
    UIBarButtonSystemItemSave,  
    UIBarButtonSystemItemAdd,
    UIBarButtonSystemItemFlexibleSpace,
    UIBarButtonSystemItemFixedSpace,
    UIBarButtonSystemItemCompose,
    UIBarButtonSystemItemReply,
    UIBarButtonSystemItemAction,
    UIBarButtonSystemItemOrganize,
    UIBarButtonSystemItemBookmarks,
    UIBarButtonSystemItemSearch,
    UIBarButtonSystemItemRefresh,
    UIBarButtonSystemItemStop,
    UIBarButtonSystemItemCamera,
    UIBarButtonSystemItemTrash,
    UIBarButtonSystemItemPlay,
    UIBarButtonSystemItemPause,
    UIBarButtonSystemItemRewind,
    UIBarButtonSystemItemFastForward,
    UIBarButtonSystemItemUndo,
    UIBarButtonSystemItemRedo,
    UIBarButtonSystemItemPageCurl//只能在ToolBar上显示
添加方法:其他类型只需将对应的Item换掉即可
UIBarButtonItem *Done  = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Done)];
    self.navigationItem.rightBarButtonItem = Done;
效果:

   UIBarButtonSystemItemDone

  UIBarButtonSystemItemCancel

   UIBarButtonSystemItemEdit  

   UIBarButtonSystemItemSave:  

    UIBarButtonSystemItemAdd:   

UIBarButtonSystemItemFlexibleSpace

UIBarButtonSystemItemFixedSpace这两种类型是不能单独用在一个Item上的,这个是在以按钮数组添加到toolBar上时用来排列位置时使用的,本文不做说明,下次再详细讲述

  UIBarButtonSystemItemCompose

 UIBarButtonSystemItemReply

 UIBarButtonSystemItemAction

  UIBarButtonSystemItemOrganize

 UIBarButtonSystemItemBookmarks

 UIBarButtonSystemItemSearch

 UIBarButtonSystemItemRefresh

 UIBarButtonSystemItemStop

 UIBarButtonSystemItemCamera

 UIBarButtonSystemItemTrash

 UIBarButtonSystemItemPlay

 UIBarButtonSystemItemPause

UIBarButtonSystemItemRewind

UIBarButtonSystemItemFastForward

UIBarButtonSystemItemUndo

UIBarButtonSystemItemRedo

 UIBarButtonSystemItemPageCurl

二、在navigationItem上添加segment,Swich等控件,效果如下图


UISegmentedControl *mySegment;
    mySegment = [[UISegmentedControl alloc] initWithFrame:CGRectMake(218.0f, 8.0, 100.0f, 30.0f)];

    [mySegment insertSegmentWithTitle:@"分配" atIndex:0 animated:YES];

    [mySegment insertSegmentWithTitle:@"处理" atIndex:1 animated:YES];

    mySegment.segmentedControlStyle = UISegmentedControlStyleBar;

    mySegment.selectedSegmentIndex = 0;

    [self.navigationController.navigationBar addSubview:mySegment];
添加switch等控件也是如此方法

转载于:https://my.oschina.net/joanfen/blog/141880

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值