日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

左右侧滑菜单功能的实现

發布時間:2025/4/9 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 左右侧滑菜单功能的实现 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

左右側滑功能是比較常見的效果,此實例實現如下的效果:

這邊使用到的SlideNavigationController開源類(引入源代碼中的Source),其為NavigationController子類,在運用程序AppDelegate就設置為其根視圖;主要代碼如下:

1:AppDelegate主要代碼如下:

#import "AppDelegate.h" #import "SlideNavigationController.h" #import "leftViewController.h" #import "rightViewController.h" #import "ViewController.h"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];self.window.backgroundColor = [UIColor whiteColor];
//設置根導航視圖ViewController
*homeVc = [[ViewController alloc] init];[self.window setRootViewController:[[SlideNavigationController alloc] initWithRootViewController:homeVc]];
//設置左右視圖leftViewController
* leftController=[[leftViewController alloc]init];rightViewController* rightController=[[rightViewController alloc]init];[SlideNavigationController sharedInstance].rightMenu = rightController;[SlideNavigationController sharedInstance].leftMenu = leftController;[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;[self.window makeKeyAndVisible];return YES; }

2:主頁面ViewController代碼:

#import <UIKit/UIKit.h> #import "SlideNavigationController.h" @interface ViewController : UIViewController<SlideNavigationControllerDelegate>@end #import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor=[UIColor yellowColor];self.title=@"首頁";UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 30)];[button setTitle:@"右邊" forState:UIControlStateNormal];[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];[SlideNavigationController sharedInstance].rightBarButtonItem = rightBarButtonItem; }- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }#pragma mark - SlideNavigationController Methods -- (BOOL)slideNavigationControllerShouldDisplayLeftMenu {return YES; }- (BOOL)slideNavigationControllerShouldDisplayRightMenu {return YES; }@end

注意要實現SlideNavigationControllerDelegate的兩個是否有左跟右的菜單,還可以設置其導航欄的按鍵樣式,如果沒有設置會像左邊出現的這種默認的;

3:左邊視圖leftViewController

#import <UIKit/UIKit.h> #import "SlideNavigationController.h" #import "OneViewController.h" #import "TwoViewController.h"@interface leftViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>@end #import "leftViewController.h"@interface leftViewController() @property(nonatomic,strong)UITableView *tableView; @property(strong,nonatomic) NSArray *listData;

@property(assign,nonatomic) bool slideOutAnimationEnabled; @end@implementation leftViewController-(void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor=[UIColor redColor];[self ininLoadTable]; }-(void)ininLoadTable {self.tableView=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];self.tableView.delegate=self;self.tableView.dataSource=self;[self.view addSubview:self.tableView];self.listData=[[NSArray alloc] initWithObjects:@"朋友圈",@"個人好友",@"最近聯系人", nil]; }#pragma mark - UITableView Delegate & Datasrouce -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return self.listData.count; }- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 20)];view.backgroundColor = [UIColor clearColor];return view; }- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {return 20; }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];if (cell==nil) {cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];}cell.textLabel.text=self.listData[indexPath.row];cell.backgroundColor = [UIColor clearColor];return cell; }//跳轉 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {UIViewController *vc ;switch (indexPath.row){case 0:vc = [[OneViewController alloc]init];break;case 1:vc = [[TwoViewController alloc]init];break;case 2:vc = [[OneViewController alloc]init];break;case 3:[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];[[SlideNavigationController sharedInstance] popToRootViewControllerAnimated:YES];return;break;}[[SlideNavigationController sharedInstance] popToRootAndSwitchToViewController:vcwithSlideOutAnimation:self.slideOutAnimationEnabledandCompletion:nil]; } @end

注意:這邊主要是進行導航跳轉時要注意,popToRootViewControllerAnimated跟popToRootAndSwitchToViewController

4:右邊的rightViewController

#import "rightViewController.h"@implementation rightViewController -(void)viewDidLoad {[super viewDidLoad];self.view.backgroundColor=[UIColor blueColor]; } @end

?

附:另外二個插件也實現更好的效果,地址如下(https://github.com/JVillella/JVFloatingDrawer)效果圖如下:

?另一個地址如下:(https://github.com/hujewelz/HUSliderMenu)效果圖如下:

源代碼下載地址:左右側滑菜單源代碼

轉載于:https://www.cnblogs.com/wujy/p/4718002.html

總結

以上是生活随笔為你收集整理的左右侧滑菜单功能的实现的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 天天看天天射 | 综合久久精品 | 精品96久久久久久中文字幕无 | 久热热 | 久久午夜神器 | 宅男的天堂 | 精品aaa | 亚洲激情视频小说 | 巨乳xxx | 日韩精品久久久久久免费 | 亚洲欧美日韩一区 | 97人妻精品视频一区 | 亚洲女人天堂网 | 美女扒开内裤让男人捅 | 激情综合五月 | 日韩欧美成人一区二区三区 | 久久精品视频一区二区三区 | 成人在线一区二区三区 | 欧美区日韩区 | 69视频免费在线观看 | 91麻豆国产在线 | 在线 日本 制服 中文 欧美 | 男女日批在线观看 | 天天干天 | 欧美色图12p | 午夜久草| 亚洲熟妇无码一区二区三区导航 | 欧美日一区二区 | 美国av片| 久久在现 | 少妇太紧太爽又黄又硬又爽小说 | 天天夜夜爽 | 99蜜桃臀久久久欧美精品网站 | 中文字幕乱伦视频 | 欧美成人免费观看视频 | 黄色网av| 一区二区精品在线 | 精品人人人人 | 日韩美女激情视频 | 亚洲一区二区三区免费在线观看 | 久久精品噜噜噜成人88aⅴ | 肉丝美脚视频一区二区 | 九色在线 | 国产在线播放一区二区三区 | 日韩永久| 中文字幕乱码在线人视频 | 俄罗斯精品一区二区三区 | a亚洲精品 | 天天草视频 | 99精品人妻无码专区在线视频区 | 欧美大浪妇猛交饥渴大叫 | 风间由美在线视频 | 麻豆影视在线免费观看 | 东方av在线播放 | 在线观看aaa| 久久婷婷五月综合色国产香蕉 | 日韩黄色大片 | 一区二区三区视频网 | 成人激情五月天 | 久久久久久久久久免费 | 少妇久久久久久被弄高潮 | 少妇久久久久久 | 精品视频亚洲 | 99热这里只有精品1 亚洲人交配视频 | 一久久久久 | 一区二区三区黄 | 在线免费成人网 | 无码人妻丰满熟妇区毛片蜜桃精品 | 午夜看毛片 | 操操操爽爽爽 | h片免费在线观看 | 日本视频一区二区三区 | 一本色道久久综合亚洲精品酒店 | 黄色av网站在线 | 男朋友是消防员第一季 | 日本xxxx18高清hd | 国产精品天干天干 | 国产乱淫av麻豆国产免费 | 2021av| 91精品国产电影 | 丁香花完整视频在线观看 | 少妇天天干| 日日摸夜夜添夜夜添高潮喷水 | 欧美14sex性hd摘花 | 狠狠久| 色av一区二区 | 人妻在线一区二区 | 日日夜夜2017 | 精品中文字幕一区二区三区 | 久久久久久久中文字幕 | 久久超碰av| 99激情视频 | av无遮挡| 人妻少妇偷人精品无码 | 久久色av | 亚洲天堂手机 | 免费色播 | 91中文字幕在线视频 | 在线高清观看免费观看 |