专业java、php、iOS、C++、网页设计、平面设计、网络营销、游戏开发、前端与移动开发培训机构
设置加号按钮frame支持iPad多任务
- 在
iPad
上运行程序,并且多任务显示,效果如下 虽然在
iPad
的horizontalSizeClass == UIUserInterfaceSizeClassRegular
iPhone
界面没有显示出来,但是CZTabBarController
被添加为CZMenuViewController
的子控制器,会响应viewWillAppear
方法,在此时获取的self.tabBar.frame
是不对的,因此在viewWillAppear
来设置加号按钮
的frame
是不合适的./// 注意:不能在这里设置加号按钮的frame,因为这个时候获取的frame是不对的 //- (void)viewWillAppear:(BOOL)animated { // [super viewWillAppear:animated]; // // [self setupComposeButton]; //} /// 控制器的view将要布局子空间 - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; [self setupComposeButton]; } /// 设置加号按钮 - (void)setupComposeButton { // 添加加号按钮 [self.tabBar addSubview:self.composeButton]; // 设置加号按钮frame CGFloat width = self.tabBar.frame.size.width / TabBarItemCount; self.composeButton.frame = CGRectMake(2 * width - 2, 0, width + 4, self.tabBar.frame.size.height); }