本项目本着能用代码
用代码的思想敲一遍,做好笔记
,方便自我回顾
和提高
### Author:Leo ### E-mail:[email protected]
===========================
##目录
- 知识点01
- tabbar封装思想(略)
- tabbar图片点击颜色
- 设置导航栏左边的按钮
- 设置导航栏右边的按钮组
- UIView+JSExtension
- 通过 appearance 统一设置所有 UITabBarItem 的文字属性(tabbar文字颜色)
-
设置导航栏左边的按钮
- 封装了
UIBarButtonItem
UIBarButtonItem+JSExtension 调用
+ (instancetype)initWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action; self.navigationItem.leftBarButtonItem = [UIBarButtonItem initWithImage:@"friendsRecommentIcon" highImage:@"friendsRecommentIcon-click" target:self action:@selector(friendsClick)];
- 封装了
-
设置导航栏右边的按钮组
self.navigationItem.rightBarButtonItems = @[settingButton, moonButton];
-
UIView+JSExtension
- 在分类中声明 @property ,只会生成方法的声明,不会生成方法的实现和带有_下划线的成员变量
@property (nonatomic, assign) CGSize size;
-
通过 appearance 统一设置所有 UITabBarItem 的文字属性
- 后面带有 UI_APPEARANCE_SELECTOR 的方法,都可以通过 appearance 对象来统一设置
NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12]; attrs[NSForegroundColorAttributeName] = [UIColor grayColor]; NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary]; selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName]; selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor]; UITabBarItem *item = [UITabBarItem appearance]; [item setTitleTextAttributes:attrs forState:UIControlStateNormal]; [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];