史上最簡單的側(cè)滑欄菜單

對于側(cè)滑欄,相信很多人都用過,下面我將用最簡單的方法實(shí)現(xiàn)一下,側(cè)滑欄菜單:

HYXSideBar *hyxsidebar = [[HYXSideBar alloc] init];
    hyxsidebar.delegate = self;
    hyxsidebar.dataArray = self.dataArray;
    [hyxsidebar callSideBarIn:self];

已經(jīng)創(chuàng)建好了一個側(cè)滑欄菜單,如圖:

側(cè)滑欄.gif

并且,該側(cè)滑欄菜單擁有UITableView的所有屬性,可以通過代理方法一一調(diào)用

/**
 獲取相應(yīng)組里面的行數(shù)

 @param tableView sidebar里面的tableview
 @param section 第幾組
 @return 返回的行數(shù)
 */
- (NSInteger)SideBar:( UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

/**
 cell的點(diǎn)擊事件

 @param tableView sidebar
 @param indexPath 點(diǎn)擊的cell位置
 */
- (void)SideBar:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
/**
 header的點(diǎn)擊事件
 
 @param tableView sidebar
 @param index 點(diǎn)擊的header的位置
 */
- (void)SideBar:(UITableView *)tableView didSelectHeaderAtIndex:(NSInteger )index;
/**
 得到相應(yīng)的cell(也是可以隨意自定義的)
 
 @param tableView sidebar里面的tableview
 @param indexPath 相應(yīng)位置里面的
 @return 返回需要的cell
 */
- (UITableViewCell *)SideBar:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

/**
 總組數(shù)

 @param tableView SideBar
 @return 返回的總組數(shù)
 */
- (NSInteger)numberOfSectionsInSideBar:(UITableView *)tableView;

/**
 每一組的header名稱

 @param tableView sidebar
 @param section 相應(yīng)的組序列
 @return  組的名稱
 */
- (NSString *)SideBar:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;

/**
 每一組的footer的名稱

 @param tableView sidebar
 @param section 相應(yīng)的組序列
 @return 每一組的footer名稱
 */
- (NSString *)SideBar:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;

/**
 cell生命周期,將要描繪出來

 @param tableView sidebar
 @param cell 將要描繪的cell
 @param indexPath cell的位置
 */
- (void)SideBar:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;

/**
 cell的高度

 @param tableView sidebar
 @param indexPath cell的位置
 @return 返回的cell的高度
 */
- (CGFloat)SideBar:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

/**
 Header的高度

 @param tableView sidebar
 @param section 組
 @return 高度
 */
- (CGFloat)SideBar:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;

/**
 footer的高度
 
 @param tableView sidebar
 @param section 組
 @return 高度
 */
- (CGFloat)SideBar:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;

/**
 返回一個描述header的view

 @param tableView sidebar
 @param section 相應(yīng)的組別
 @return 返回的viwe
 */
- (UIView *)SideBar:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
/**
 返回一個描述header的view
 
 @param tableView sidebar
 @param section 相應(yīng)的組別
 @return 返回的viwe
 */
- (UIView *)SideBar:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
如此就可以對側(cè)邊欄進(jìn)行個性化設(shè)置了。

奉上demo:史上最簡單的側(cè)邊欄

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,704評論 4 61
  • 小時候,家里很窮。 我小時候的家是一間江南獨(dú)有的地主豪宅。我只記得那房子很深,中間有一個很大的天井,天井下放了一口...
    八田草閱讀 2,164評論 18 33
  • 人,不論美丑,平安健康就好;天,不論陰晴,心情愉悅就好;路,不論遠(yuǎn)近,堅持走完就好;情,不論淡濃,真心相待就好。生...
    映卿閱讀 256評論 0 0
  • 兒童節(jié)快到了。跟4歲的小侄女視頻,對話如下: 我:朵朵想姑姑沒有哇~ 朵:不想不想 我: /palmface 那算...
    浣叢素手閱讀 169評論 0 0
  • 我的閨蜜身材很好,容貌也是絕佳,每次都是帶妝出門,引得路人紛紛回頭。她可謂是幸運(yùn)兒,身邊不乏各種追求者。前幾天和我...
    老綏遠(yuǎn)Richard閱讀 470評論 0 0

友情鏈接更多精彩內(nèi)容