iOS价格日历

SkyCalendarPriceView


测试环境:Xcode 6,iOS 7.0以上。

github地址 : https://github.com/skytoup/SkyCalendarPriceView

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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值