IOS中UITableView和NavigationBar常用设置的示例分析

小编给大家分享一下IOS中UITableView和NavigationBar常用设置的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、成都网站设计、成都外贸网站建设、扎鲁特旗网络推广、成都小程序开发、扎鲁特旗网络营销、扎鲁特旗企业策划、扎鲁特旗品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供扎鲁特旗建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com

IOS UITableView和NavigationBar的常用设置详解

TableView:

1.tableview常用基本设置

// 清除父类UIEdgeInsets 
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0,0); 
//禁止滚动 
self.tableView.scrollEnabled = NO; 
// tableview头部视图设置 
self.tableView.tableHeaderView =一个UIView; 
//tableview尾部视图设置,这样用一个不占空间的UIView初始化可以清除尾部多余空格 
self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero]; 
//表格背景色 
self.tableView.backgroundColor = [UIColorgrayColor]; 
//取消垂直滚动条 
self.tableView.showsVerticalScrollIndicator=NO; 
//设置表格背景图片 
UIView *bgView= [[UIView alloc]initWithFrame:CGRectMake(0,20,SLApplicationW,SLApplicationH)]; 
UIImageView *bgImageView= [[UIImageView alloc]initWithFrame:CGRectMake(0,0,SLApplicationW,SLApplicationH)]; 
  [bgImageView setImage:[UIImageimageNamed:@"tree"]]; 
  [bgView addSubview:bgImageView]; 
self.tableView.backgroundView= bgView;

2.cell常用基本设置

//表格附件样式,指示箭头 
  
  cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; 
//禁止点击变色 
  
  cell.selectionStyle=UITableViewCellSelectionStyleNone;

3.cell分割线左侧空白清除     

IOS中UITableView和NavigationBar常用设置的示例分析IOS中UITableView和NavigationBar常用设置的示例分析

//分割线清偏移 
  if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { 
    [cellsetSeparatorInset:UIEdgeInsetsZero]; 
  }
//分割线清边界(没啥变化) 
  if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { 
    [cellsetLayoutMargins:UIEdgeInsetsZero]; 
  }
//清除父边界 
  if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){ 
    [cellsetPreservesSuperviewLayoutMargins:NO]; 
  
  }

NavigationBar导航栏:

1.常用基本设置

self.title =@"标题"; 
// 导航栏颜色 
self.navigationBar.barTintColor=[UIColor grayColor]; 
// 导航栏文字颜色 
self.navigationBar.tintColor=[UIColor whiteColor]; 
// 导航栏标题颜色 
NSMutableDictionary*textAttrs= [NSMutableDictionary dictionary]; 
 textAttrs[NSForegroundColorAttributeName] =[UIColor whiteColor]; 
self.navigationBarsetTitleTextAttributes:textAttrs]; 
  
//导航栏按钮1 
UIBarButtonItem*button1= [[UIBarButtonItem alloc] 
             initWithBarButtonSystemItem:UIBarButtonSystemItemAddtarget:selfaction:@selector(function1)]; 
//导航栏按钮2 
UIBarButtonItem*button2= [[UIBarButtonItem alloc] 
              initWithBarButtonSystemItem:UIBarButtonSystemItemSearchtarget:selfaction:@selector(function2)]; 
//将按钮添加到导航栏右侧(可以添加多个) 
  
self.navigationItem.rightBarButtonItems=@[button1, button2];

2.系统自带按钮

枚举定义及样式解释如下:

typedef NS_ENUM(NSInteger, UIBarButtonSystemItem) { 
  UIBarButtonSystemItemDone,   //Done英文字符 
  UIBarButtonSystemItemCancel,  //Cancel 
  UIBarButtonSystemItemEdit,   //Edit 
  UIBarButtonSystemItemSave,   //Save  
  UIBarButtonSystemItemAdd,    //图标1(加号图标➕) 
  UIBarButtonSystemItemFlexibleSpace, //?空白 
  UIBarButtonSystemItemFixedSpace,   //?空白 
  UIBarButtonSystemItemCompose,    //图标2(写字板上一支笔写字的图标) 
  UIBarButtonSystemItemReply,     //图标3 
  UIBarButtonSystemItemAction,     //图标4 
  UIBarButtonSystemItemOrganize,    //图标5 
  UIBarButtonSystemItemBookmarks,   //图标6 
  UIBarButtonSystemItemSearch,     //图标7 
  UIBarButtonSystemItemRefresh,    //图标8 
  UIBarButtonSystemItemStop,      //图标9 
  UIBarButtonSystemItemCamera,     //图标10 
  UIBarButtonSystemItemTrash,     //图标11 
  UIBarButtonSystemItemPlay,      //图标12 
  UIBarButtonSystemItemPause,     //图标13 
  UIBarButtonSystemItemRewind,     //图标14 
  UIBarButtonSystemItemFastForward,  //图标15 
  UIBarButtonSystemItemUndo NS_ENUM_AVAILABLE_IOS(3_0),    //Redo 
  UIBarButtonSystemItemRedo NS_ENUM_AVAILABLE_IOS(3_0),    //Undo 
  UIBarButtonSystemItemPageCurl NS_ENUM_AVAILABLE_IOS(4_0),  //?空白 
};

以上是“IOS中UITableView和NavigationBar常用设置的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


文章题目:IOS中UITableView和NavigationBar常用设置的示例分析
标题URL:http://lszwz.com/article/iegshg.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款