// // MessageViewController.m // watch // // Created by xTT on 2017/7/13. // Copyright © 2017年 xTT. All rights reserved. // #import "MessageViewController.h" #import "MessageBaseViewController.h" #import "DLTabedSlideView.h" #import "RemindMessageViewController.h" #import "AttentionMessageViewController.h" #import "SystermMessageViewController.h" #import "CallMessageViewController.h" @interface MessageViewController () @property (strong, nonatomic) DLTabedSlideView *tabedSlideView; @property (nonatomic ,strong) UIBarButtonItem *rightBarButton; @property (nonatomic ,strong) NSMutableArray *VCArray; @end @implementation MessageViewController - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.view.backgroundColor = [UIColor whiteColor]; if(self.VCArray.count > self.selectedIndex){ UIViewController *vc = self.VCArray[self.selectedIndex]; [vc viewWillAppear:YES]; } } - (void)setSelectedIndex:(NSInteger)selectedIndex{ if(_selectedIndex != selectedIndex){ _selectedIndex = selectedIndex; if(self.tabedSlideView){ [self.tabedSlideView DLSlideTabbar:nil selectAt:selectedIndex]; } } } - (void)viewDidLoad { [super viewDidLoad]; self.VCArray = [NSMutableArray array]; //[self setRightBarBtnTitle:nil RoImage:[UIImage imageNamed:@"icon_delete"]]; // self.navigationController.navigationBarHidden = YES; self.zx_navRightBtn.zx_fixImageSize = CGSizeMake(30, 30); [self zx_setRightBtnWithImg:ImageName_(@"icon_delect_black") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) { [self setDeleteModel]; }]; self.tabedSlideView = [[DLTabedSlideView alloc] initWithFrame:CGRectMake(0, iPhoneX_NavHeight, ScreenWidth, ScreenHeight-iPhoneX_NavHeight)]; self.tabedSlideView.delegate = self; self.tabedSlideView.baseViewController = self; self.tabedSlideView.tabItemNormalColor = KKGrey102; self.tabedSlideView.tabItemSelectedColor = KKBlack20; self.tabedSlideView.tabbarTrackColor = mainColor; //self.tabedSlideView.tabbarBackgroundImage = [UIImage imageNamed:@"tabbarBk"]; self.tabedSlideView.tabbarBottomSpacing = 0; self.tabedSlideView.tabbarHeight = 40; DLTabedbarItem *item1 = [DLTabedbarItem itemWithTitle:@"提醒" image:nil selectedImage:nil]; DLTabedbarItem *item2 = [DLTabedbarItem itemWithTitle:@"关注记录" image:nil selectedImage:nil]; DLTabedbarItem *item3 = [DLTabedbarItem itemWithTitle:@"通知" image:nil selectedImage:nil]; DLTabedbarItem *item4 = [DLTabedbarItem itemWithTitle:@"通话记录" image:nil selectedImage:nil]; self.tabedSlideView.tabbarItems = @[item1, item2, item3, item4]; [self.tabedSlideView buildTabbar]; self.tabedSlideView.selectedIndex = self.selectedIndex; [self.view addSubview:self.tabedSlideView]; } -(void)setDeleteModel{ MessageBaseViewController *vc = self.childViewControllers[0]; if([vc respondsToSelector:@selector(deletAction)]){ //进入删除模式 [vc deletAction]; } } - (NSInteger)numberOfTabsInDLTabedSlideView:(DLTabedSlideView *)sender{ return 3; } - (UIViewController *)DLTabedSlideView:(DLTabedSlideView *)sender controllerAt:(NSInteger)index{ switch (index) { case 0: { RemindMessageViewController *ctrl = [[RemindMessageViewController alloc] init]; [self.VCArray addObject:ctrl]; return ctrl; } case 1: { AttentionMessageViewController *ctrl = [[AttentionMessageViewController alloc] init]; [self.VCArray addObject:ctrl]; return ctrl; } case 2: { SystermMessageViewController *ctrl = [[SystermMessageViewController alloc] init]; [self.VCArray addObject:ctrl]; return ctrl; } case 3: { CallMessageViewController *ctrl = [[CallMessageViewController alloc] init]; [self.VCArray addObject:ctrl]; return ctrl; } default: return nil; } } - (void)DLTabedSlideView:(DLTabedSlideView *)sender didSelectedAt:(NSInteger)index{ self.selectedIndex = index; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end