CIComponentKit 是一个由 ManoBoo & NEWWORLD 支持和维护的基础组件库,里面包含了一些基础库 UIKit 和 UIFoundation 的 Categories ,通过使用链式写法,添加前缀 cic. 可快速设置组件属性创建视图,也包含了一些常用视图组件的封装。
当前 CICKit 支持 Objective-C 语言,如使用 Swift 语言,使用 CIComponentKit 更方便。
- Categories for
UIImage,UIButton,UIImageView,UILabel等 -
CICNumberKeyboardView自定义10位数字键盘 -
CICVerifyPayPasswordView类似微信的密码输入框 -
CICTabBarController支持动态更新tabbar图片、文字、背景及颜色 - 后续更多便捷功能正在开发中...
添加下面指定内容到自己的Podfile文件中
platfor: ios, '8.0'
target 'TargetName' do
pod 'CICKit', '~> 0.0.3.4'
end打开终端,在项目路径下,执行下面的命令
$ pod install
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.CICTabBarController 可快速创建app框架
-
首先必须传递
TabbarController对应的类名数组classNameData,不需要引入类所对应的.h文件 -
imageSize设置显示图片的大小,在更新图片数据之前设置 -
selectedTextColor设置TabbarItem文字选中的颜色,normalTextColor设置TabbarItem文字未选中的颜色 (设置的颜色未修改[UITabBarItem appearance],不会引起全局TabbarItem颜色变化) -
几种方式更新
Tabbar数据:包含图片名称或者url链接,按照展示的顺序排列,未选中TabbarItem时系统会根据数组里的图片,自动生成相应的模板图片显示,选中时显示数组内的图片;初始显示标题的Tabbar动态不显示标题时,数据数组内标题可传@""-
只更新图片
itemDataNormalImage@[@"home_tabbar_icon", @"home_tabbar_icon", @"tool_tabbar_icon"]
-
更新图片和文字
itemDataTitleNormalImage@[@[@"首页", @"home_tabbar_icon"], @[@"聚中", @"center_tabbar_icon"], @[@"工具", @"tool_tabbar_icon"]]
-
更新未选中的图片和选中的图片
itemDataNormalSelectedImage -
更新标题、未选中的图片和选中的图片
itemDataTitleNormalSelectedImage
-
-
badgeValue设置TabbarItem角标,两个参数:TabbarItem位置 和 显示的内容
CICTabBarController *tabbarController = [[CICTabBarController alloc] init];
// 首先设置类名数据
tabbarController.cic
.classNameData(@[@"ViewController", @"ViewController", @"ViewController"])
.itemDataTitleNormalImage(@[@[@"首页", @"home_tabbar_icon"],
@[@"聚中", @"center_tabbar_icon"],
@[@"工具", @"tool_tabbar_icon"]])
.selectedTextColor([UIColor cic_hexColor:0x1296db])
.normalTextColor([UIColor cic_hexColor:0x646464])
.badgeValue(2, @"100");
self.window.rootViewController = tabbarController;
// 动态加载tabbar图片的数据
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// NSArray *urls = [NSArray array];
// tabbarController.cic.itemDataNormalSelectedImage(urls).barBackgroundImage(@"");
tabbarController.cic.imageSize(CGSizeMake(34, 34))
.itemDataTitleNormalImage(@[@[@"",@"home_tabbar_icon"],
@[@"",@"center_tabbar_icon"],
@[@"",@"tool_tabbar_icon"]]);
tabbarController.didSelectedTabbarBlock = ^(NSInteger selectedIndex) {
NSLog(@"selectedIndex = %ld", selectedIndex);
};
});CICNumberKeyboardView 是一个展示10位数字的键盘视图,支持顺序数字 CICKeyboardTypeNumber 排列和随机数字 CICKeyboardTypeRandomNumber 两种。
-
获取0-9随机不重复的数组
numberData:初始化一个存储顺序数字的数组tempArray,生成包含所有下标的随机数字,根据下标取数组中的元素加入数组numberData,tempArray将该元素移除;重复前面的过程,直至tempArray的元素个数为0后,numberData已存储了无序的0-9数字。 -
根据键盘输入的数值
value是否为nil确认,该键为数字键或者删除键。
CICNumberKeyboardView *keyboardView = [CICNumberKeyboardView keyboardViewWithType:CICKeyboardTypeNumber];
WEAK_SELF;
keyboardView.clickKeyboardButtonBlock = ^(NSString * _Nonnull value) {
[weakSelf handleKeyboardInputValue:value];
};CICNumberKeyboardView *keyboardView = [CICNumberKeyboardView keyboardViewWithType:CICKeyboardTypeRandomNumber keyboardHeight:200];CICVerifyPayPasswordView 是一个类似微信的密码输入框,使用上述的 CICNumberKeyboardView 数字键盘(默认随机数字样式)。
- 该输入框中,显示键盘输入内容的每个小黑点是一张图片,通过键盘的输入和删除,控制每个小黑点的展示和隐藏
- 该输入框中不包含
TextField,不支持粘贴密码。
CGFloat width = 300;
CICVerifyPayPasswordView *verifyPasswordView = [CICVerifyPayPasswordView verifyPayPasswordViewWithFrame:CGRectMake((CIC_SCREEN_WIDTH - width)/2.0, 200, width, 50) showKeyboardBottomHeight:CIC_TAB_BAR_HEIGHT keyboardHeight:0 keyboardType:CICKeyboardTypeRandomNumber verifyPayPasswordBlock:^(NSString * _Nonnull password) {
}];
[verifyPasswordView cic_addTo:self.view];CICKit is released under the MIT license. See LICENSE for details.