百思不得姐知识点
tabBarItem字符属性
1 | NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary]; |
设置自定义tabBar控制器
1 | self.window.rootViewController = [[XMGTabBarController alloc] init]; |
pch常见宏
1 | /***** 在#ifdef __OBJC__和#endif之间的内容, 只会拷贝到OC源代码文件中, 不会拷贝到其他语言的源代码文件中 *****/ |
利用Appearance实现简单的换肤
1 | [UISwitch appearance].onTintColor = [UIColor orangeColor]; |
发布按钮
当viewWillAppear:方法被调用的时候, tabBar内部已经添加了5个UITabBarButton
* 就可以实现一个效果 : [发布按钮]盖在其他UITabBarButton上面
1 | - (void)viewWillAppear:(BOOL)animated |
自定义tabBar
打印方法名
1 |
找到中间按钮 NSClassFromString
1 | if (subview.class != NSClassFromString(@"UITabBarButton")) continue; |
KVC设置tabBar
1 | [self setValue:[[XMGTabBar alloc] init] forKeyPath:@"tabBar"]; |
完善代码
frame.x 方便访问 UIView+XMGExtension.h
设置BarButtonItem
1 | self.navigationItem.rightBarButtonItems = @[settingItem, moonItem]; |
UIBarButtonItem+Extension.h
1 | + (instancetype)itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action |
统一添加返回item
1 | - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated |
1 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer |