集成iOS开发中常用功能模块.
GitHub:何青云 | Blog:江城程序猿 | Contact me:developerqingyun@gmail.com
##目录
-
备注:浏览时,gif图偶尔会有非代码原因的卡顿.
###UICollectionView重排
####实现思路:
1 分别使用两个继承于UITableViewController
的控制器管理左右两侧菜单,分别命名为HQYMainCategoryController
(左菜单控制器)和HQYSubCategoryController
(右菜单控制器).
2 使用导航控制器push
出来的控制器(命名为HQYCascadingMenuController
)来管理HQYMainCategoryController
和HQYSubCategoryController
,将HQYMainCategoryController
和HQYSubCategoryController
添加为HQYCascadingMenuController
的子控制器,并将子控制器的view
作为子控件添加到HQYCascadingMenuController
的view
中.
3 使用代理传值,将HQYMainCategoryController
中的数据传递给HQYSubCategoryController
.
####注意事项:
1 默认HQYMainCategoryController
的view
第0行cell
应该处于选中状态,该业务逻辑应该在viewWillAppear
方法中实现,而非在viewDidLoad
方法中实现.
- (void)viewWillAppear:(BOOL)animated{
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:(UITableViewScrollPositionTop)];
// 显示第0行数据
[self showSubCategoriesDataOfArrowZero];
}
2 默认HQYSubCategoryController
的view
展示HQYMainCategoryController
的view
第0行cell
对应的数据.
- (void)showSubCategoriesDataOfArrowZero{
if ([self.delegate respondsToSelector:@selector(categoryViewController:didSelectSubCategories:)]) {
NSDictionary *dict = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"health.plist" ofType:nil]][0];
HYQHealthItem *item = [HYQHealthItem categoryWithDict:dict];
[self.delegate categoryViewController:self didSelectSubCategories:item.subcategories];
}
}
####实现过程:
1 拿到UIStatusBarForegroundView
对象
UIApplication *app = [UIApplication sharedApplication];
UIView *statusBar = [app valueForKeyPath:@"statusBar"];
statusBar.frame = (CGRect){0, 100, 350, 50};
statusBar.center = self.view.center;
statusBar.backgroundColor = [UIColor orangeColor];
UIView *barForegroundView = statusBar.subviews[1];
2 对系统状态栏的私有属性进行个性化设置(以网络服务商为例)
UIView *seviceView = barForegroundView.subviews[0];
CGRect seviceFrame = seviceView.frame;
seviceFrame.size.width = 2 * seviceFrame.size.width;
seviceView.frame = seviceFrame;
seviceView.hidden = YES;
UILabel *seviceLabel = [[UILabel alloc] init];
seviceLabel.frame = seviceFrame;
seviceLabel.text = @"66666";
seviceLabel.font = [UIFont systemFontOfSize:10];
[barForegroundView addSubview:seviceLabel];
####注意事项: 1 不能将downMenuView添加到主窗口中
[[UIApplication sharedApplication].keyWindow addSubview:downMenuView];
而应该添加到HQYDownMenu中
####实现过程:
待续 😄