iOS价格日历
2015-08-27 10:17
495 查看
SkyCalendarPriceView
测试环境:Xcode 6,iOS 7.0以上。
github地址 : https://github.com/skytoup/SkyCalendarPriceView![](https://github.com/skytoup/SkyCalendarPriceView/raw/master/1.gif)
简介
一个可以自定义样式的价格日历高度封装,简单使用,传入对应的数据模型即可显示
灵活度高,大部分view的样式可调整
显示的文字可自定义处理,也可以自定义和系统处理一起使用
可在Xib或StoryBoard中拖拽使用,也支持自动布局,也可以手写固定的Frame
支持旋屏
使用方法
把头文件SkyCalendarPriceView.h导入项目。
#import "SkyCalendarPriceView.h"
基本使用
// 创建价格日历 SkyCalendarPriceView *v = [SkyCalendarPriceView calendarPriceView]; // 创建数据模型 SkyCalendarPriceModel *model = [SkyCalendarPriceModel calendarPriceModelWithYear:@(2015) withMonth:@(3) withDay:@(22) withPrice:@(30) withCount:@(10)]; SkyCalendarPriceModel *model2 = [SkyCalendarPriceModel calendarPriceModelWithYear:@(2015) withMonth:@(9) withDay:@(22) withPrice:@(10) withCount:@(10)]; SkyCalendarPriceModel *model3 = [SkyCalendarPriceModel calendarPriceModelWithYear:@(2015) withMonth:@(7) withDay:@(24) withPrice:@(20) withCount:@(10)]; // 导入数据模型 _v.datas = @[model, model2, model3]; // 设置今天的时间,可不设置 _v.today = [NSDate date];
定制样式
详情请看SkyCalendarPriceViewConfig.h代码修改部分view样式
// 可通过调用以下几个方法 SkyCalendarHeader + (void)SkyCalendarPriceViewInitHeaderViewOfYearMonthViewStyleWithBlock:(void(^)(UIView *view))block + (void)SkyCalendarPriceViewInitHeaderViewOfWeekLabelsStyleWithBlock:(void(^)(NSArray *labels))block; SkyCalendarCell + (void)SkyCalendarPriceViewInitCellStyleWithBlock:(void(^)(UICollectionViewCell *cell))block;
自定义显示的数据样式
// 通过实现SkyCalendarPriceViewDelegate的方法进行显示自定义的数据样式 - (NSDictionary*)skyCalendarPriceView:(SkyCalendarPriceView*)cview cellDataStringDictionaryWithIndexPath:(NSIndexPath*)indexPath withYear:(NSString*)year withMonth:(NSString*)month withDay:(NSString*)day withPrice:(NSString*)price withCount:(NSString*)count withIsToday:(BOOL)isToady; - (NSString*)skyCalendarPriceView:(SkyCalendarPriceView*)cview cellDayStringWithYear:(NSString*)year withMonth:(NSString*)month withDay:(NSString*)day withIsToday:(BOOL)isToday; - (NSString*)skyCalendarPriceView:(SkyCalendarPriceView *)cview headerLabelStringWithYear:(NSString*)year withMonth:(NSString*)month;
若不需要header停留在顶部
// 更换默认布局(注:Xib或StoryBoard中,需手动在代码或面板里设置Layout,设置的Layout需要为UICollectionViewFlowLayout的子类) skyCalendarPriceView.collectionViewLayout = [UICollectionViewFlowLayout new];
监听选中/取消选中日期
// 通过实现SkyCalendarPriceViewDelegate的方法进行监听 - (BOOL)skyCalendarPriceView:(SkyCalendarPriceView*)cview shouldSelectIndexWithPriceModel:(SkyCalendarPriceModel*)model; - (void)skyCalendarPriceView:(SkyCalendarPriceView*)cview didUnselectIndexWithPriceModel:(SkyCalendarPriceModel*)model;
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- jQuery支持添加事件的日历特效代码分享(3种样式)
- 简单JavaScript日历及详细说明
- 兼容FireFox 的 js 日历 支持时间的获取
- javascript实现的淘宝旅行通用日历组件用法实例
- jQuery简单实现日历的方法
- 一个用JSP做的日历
- 用 php 编写的日历
- js判断客户端是iOS还是Android等移动终端的方法
- IOS开发环境windows化攻略
- C#实现功能强大的中国农历日历操作类
- c语言实现一个简单日历
- .net平台推送ios消息的实现方法
- php实现的日历程序