IOS UITableView和NavigationBar的常用設(shè)置詳解
IOS UITableView和NavigationBar的常用設(shè)置詳解
TableView:
1.tableview常用基本設(shè)置
// 清除父類UIEdgeInsets self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0,0); //禁止?jié)L動(dòng) self.tableView.scrollEnabled = NO; // tableview頭部視圖設(shè)置 self.tableView.tableHeaderView =一個(gè)UIView; //tableview尾部視圖設(shè)置,這樣用一個(gè)不占空間的UIView初始化可以清除尾部多余空格 self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero]; //表格背景色 self.tableView.backgroundColor = [UIColorgrayColor]; //取消垂直滾動(dòng)條 self.tableView.showsVerticalScrollIndicator=NO; //設(shè)置表格背景圖片 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常用基本設(shè)置
//表格附件樣式,指示箭頭 cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; //禁止點(diǎn)擊變色 cell.selectionStyle=UITableViewCellSelectionStyleNone;
3.cell分割線左側(cè)空白清除
//分割線清偏移 if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { [cellsetSeparatorInset:UIEdgeInsetsZero]; }
//分割線清邊界(沒(méi)啥變化) if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { [cellsetLayoutMargins:UIEdgeInsetsZero]; }
//清除父邊界 if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){ [cellsetPreservesSuperviewLayoutMargins:NO]; }
NavigationBar導(dǎo)航欄:
1.常用基本設(shè)置
self.title =@"標(biāo)題"; // 導(dǎo)航欄顏色 self.navigationBar.barTintColor=[UIColor grayColor]; // 導(dǎo)航欄文字顏色 self.navigationBar.tintColor=[UIColor whiteColor]; // 導(dǎo)航欄標(biāo)題顏色 NSMutableDictionary*textAttrs= [NSMutableDictionary dictionary]; textAttrs[NSForegroundColorAttributeName] =[UIColor whiteColor]; self.navigationBarsetTitleTextAttributes:textAttrs]; //導(dǎo)航欄按鈕1 UIBarButtonItem*button1= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAddtarget:selfaction:@selector(function1)]; //導(dǎo)航欄按鈕2 UIBarButtonItem*button2= [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearchtarget:selfaction:@selector(function2)]; //將按鈕添加到導(dǎo)航欄右側(cè)(可以添加多個(gè)) self.navigationItem.rightBarButtonItems=@[button1, button2];
2.系統(tǒng)自帶按鈕
枚舉定義及樣式解釋如下:
typedef NS_ENUM(NSInteger, UIBarButtonSystemItem) { UIBarButtonSystemItemDone, //Done英文字符 UIBarButtonSystemItemCancel, //Cancel UIBarButtonSystemItemEdit, //Edit UIBarButtonSystemItemSave, //Save UIBarButtonSystemItemAdd, //圖標(biāo)1(加號(hào)圖標(biāo)➕) UIBarButtonSystemItemFlexibleSpace, //?空白 UIBarButtonSystemItemFixedSpace, //?空白 UIBarButtonSystemItemCompose, //圖標(biāo)2(寫字板上一支筆寫字的圖標(biāo)) UIBarButtonSystemItemReply, //圖標(biāo)3 UIBarButtonSystemItemAction, //圖標(biāo)4 UIBarButtonSystemItemOrganize, //圖標(biāo)5 UIBarButtonSystemItemBookmarks, //<span style="font-family: Menlo;">圖標(biāo)6</span> UIBarButtonSystemItemSearch, //<span style="font-family: Menlo;">圖標(biāo)7</span> UIBarButtonSystemItemRefresh, //<span style="font-family: Menlo;">圖標(biāo)8</span> UIBarButtonSystemItemStop, //圖標(biāo)9 UIBarButtonSystemItemCamera, //圖標(biāo)10 UIBarButtonSystemItemTrash, //圖標(biāo)11 UIBarButtonSystemItemPlay, //圖標(biāo)12 UIBarButtonSystemItemPause, //圖標(biāo)13 UIBarButtonSystemItemRewind, //圖標(biāo)14 UIBarButtonSystemItemFastForward, //圖標(biāo)15 UIBarButtonSystemItemUndo NS_ENUM_AVAILABLE_IOS(3_0), //Redo UIBarButtonSystemItemRedo NS_ENUM_AVAILABLE_IOS(3_0), //Undo UIBarButtonSystemItemPageCurl NS_ENUM_AVAILABLE_IOS(4_0), //?空白 };
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- ios UITableView實(shí)現(xiàn)無(wú)數(shù)據(jù)加載占位圖片
- iOS中UIScrollView嵌套UITableView的實(shí)踐教程
- iOS中UITableView使用的常見(jiàn)問(wèn)題總結(jié)
- iOS基于UITableView實(shí)現(xiàn)多層展開與收起
- iOS中UITableView Cell實(shí)現(xiàn)自定義單選功能
- iOS中的UITableView的重用機(jī)制與加載優(yōu)化詳解
- IOS UITableViewCell詳解及按鈕點(diǎn)擊事件處理實(shí)例
- IOS中UITableView滾動(dòng)到指定位置
- IOS UITableView顏色設(shè)置的實(shí)例詳解
相關(guān)文章
iOS逆向工程使用dumpdecrypted工具給App脫殼
這篇文章主要介紹了iOS逆向工程使用dumpdecrypted工具給App脫殼的相關(guān)資料,本文圖文并茂給大家介紹的非常詳細(xì),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09關(guān)于iOS自帶九宮格拼音鍵盤和Emoji表情之間的一些坑
這篇文章主要給大家介紹了關(guān)于iOS自帶九宮格拼音鍵盤和Emoji表情之間的一些坑文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-05-05如何實(shí)現(xiàn)IOS_SearchBar搜索欄及關(guān)鍵字高亮
本文通過(guò)實(shí)例代碼演示如何實(shí)現(xiàn)IOS搜索欄及搜索關(guān)鍵字高亮,效果很棒,小編覺(jué)得對(duì)大家的學(xué)習(xí)會(huì)很有幫助,現(xiàn)在分享給大家,有需要的可以參考學(xué)習(xí)。2016-08-08iOS實(shí)現(xiàn)簡(jiǎn)單的頭部縮放功能
這篇文章主要介紹了iOS 簡(jiǎn)單的頭部縮放效果,頭部伴隨模糊效果放大縮小,并在一定位置時(shí)懸停充當(dāng)導(dǎo)航欄,本文給大家提供實(shí)現(xiàn)思路,需要的朋友可以參考下2018-08-08IOS10.11 無(wú)法訪問(wèn)http的問(wèn)題解決辦法
這篇文章主要介紹了IOS10.11 無(wú)法訪問(wèn)http的問(wèn)題解決辦法的相關(guān)資料,需要的朋友可以參考下2016-12-12詳解IOS開發(fā)中圖片上傳時(shí)兩種圖片壓縮方式的比較
這篇文章主要介紹了IOS開發(fā)中圖片上傳時(shí)兩種圖片壓縮方式的比較,需要的朋友可以參考下2017-03-03詳解iOS開發(fā)中UItableview控件的數(shù)據(jù)刷新功能的實(shí)現(xiàn)
這篇文章主要介紹了詳解iOS開發(fā)中UItableview控件的數(shù)據(jù)刷新功能的實(shí)現(xiàn),代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-12-12