[IOS]通过子view控制tab的页面转换

网友投稿 692 2022-09-03

[IOS]通过子view控制tab的页面转换

[IOS]通过子view控制tab的页面转换

-(void)setSelectButton:(UIButton*)sender{ if(sender == _btPayQR && ![_btPayQR isSelected]){ [_btPayScan setBackgroundColor:[UIColor whiteColor]]; [_bgView setBackgroundColor:[UIColor whiteColor]]; [_btPayScan setSelected:false]; [_btTranSporttation setSelected:false]; [sender setBackgroundColor:[[UIColor alloc] initWithRed:115/255.0 green:115/255.0 blue:115/255.0 alpha:1]]; [sender setSelected:YES]; [self addChildViewWithStoryboardName:@"PToM" identifier:@"PGPToMQRCodeViewController"]; }else if(sender == _btPayScan && ![_btPayScan isSelected]){ [_btPayQR setBackgroundColor:[UIColor whiteColor]]; [_bgView setBackgroundColor:[UIColor whiteColor]]; [_btPayQR setSelected:false]; [_btTranSporttation setSelected:false]; [sender setBackgroundColor:[[UIColor alloc] initWithRed:115/255.0 green:115/255.0 blue:115/255.0 alpha:1]]; [sender setSelected:YES]; [self addChildViewWithStoryboardName:@"PToM" identifier:@"PGPToMScanViewController"];

在当前页面做tab的翻页

- (void)addChildViewWithStoryboardName:(NSString *)storyboardName identifier:(NSString *)identifier { if ([self.subView.subviews count] != 0) { [self.subView.subviews[0] removeFromSuperview]; } UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; PGBaseViewController *controller = [storyboard instantiateViewControllerWithIdentifier:identifier]; [self addChildViewController:controller]; [controller.view setBackgroundColor:[UIColor clearColor]]; [controller.view setFrame:self.subView.bounds]; [self.subView addSubview:controller.view];}

清空subview数组并加载子页面

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SQL Server数据库水平分区分表实例(sql增删改查基本语法)
下一篇:[IOS]NSString转int数据丢失
相关文章

 发表评论

暂时没有评论,来抢沙发吧~