├── gif
└── CCTimePickerGIF.gif
├── CCTimePickerDemo.xcodeproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcuserdata
│ │ └── ehome.xcuserdatad
│ │ └── UserInterfaceState.xcuserstate
└── xcuserdata
│ └── ehome.xcuserdatad
│ ├── xcschemes
│ ├── xcschememanagement.plist
│ └── CCTimePickerDemo.xcscheme
│ └── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
├── CCTimePickerDemo
├── ViewController.h
├── CCTimePicker
│ ├── vendor
│ │ ├── JTCalendar
│ │ │ ├── JTCircleView.h
│ │ │ ├── JTCalendarDataCache.h
│ │ │ ├── JTCalendarMenuView.h
│ │ │ ├── JTCalendarMonthWeekDaysView.h
│ │ │ ├── JTCalendarMenuMonthView.h
│ │ │ ├── JTCalendarMonthView.h
│ │ │ ├── JTCalendarContentView.h
│ │ │ ├── JTCalendarDayView.h
│ │ │ ├── JTCalendarWeekView.h
│ │ │ ├── JTCalendarViewDataSource.h
│ │ │ ├── JTCircleView.m
│ │ │ ├── JTCalendar.h
│ │ │ ├── JTCalendarDataCache.m
│ │ │ ├── JTCalendarMenuMonthView.m
│ │ │ ├── JTCalendarAppearance.h
│ │ │ ├── JTCalendarWeekView.m
│ │ │ ├── JTCalendarMonthWeekDaysView.m
│ │ │ ├── JTCalendarMenuView.m
│ │ │ ├── JTCalendarAppearance.m
│ │ │ ├── JTCalendarMonthView.m
│ │ │ └── JTCalendarContentView.m
│ │ └── Masonry
│ │ │ ├── MASLayoutConstraint.m
│ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h
│ │ │ ├── MASLayoutConstraint.h
│ │ │ ├── MASCompositeConstraint.h
│ │ │ ├── Masonry.h
│ │ │ ├── ViewController+MASAdditions.h
│ │ │ ├── NSArray+MASShorthandAdditions.h
│ │ │ ├── MASViewAttribute.m
│ │ │ ├── MASViewAttribute.h
│ │ │ ├── ViewController+MASAdditions.m
│ │ │ ├── MASViewConstraint.h
│ │ │ ├── MASConstraint+Private.h
│ │ │ ├── NSArray+MASAdditions.h
│ │ │ ├── View+MASShorthandAdditions.h
│ │ │ ├── View+MASAdditions.h
│ │ │ ├── MASCompositeConstraint.m
│ │ │ ├── MASConstraintMaker.h
│ │ │ ├── View+MASAdditions.m
│ │ │ └── NSLayoutConstraint+MASDebugAdditions.m
│ ├── NSDate+CCUtil.h
│ ├── CCHourCircleSlider.h
│ ├── UIView+CCUtil.h
│ ├── CCYearPickerView.h
│ ├── CCMiniteCircleSlider.h
│ ├── CCMinitePickerView.h
│ ├── CCDatePickerView.h
│ ├── CCHourPickerView.h
│ ├── CCTimePickerView.h
│ ├── NSDate+CCUtil.m
│ ├── CCDatePickerView.m
│ ├── CCYearPickerView.xib
│ ├── UIView+CCUtil.m
│ ├── CCYearPickerView.m
│ ├── CCHourPickerView.m
│ ├── CCMinitePickerView.m
│ └── CCDatePickerView.xib
├── AppDelegate.h
├── main.m
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── ViewController.m
├── Info.plist
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
└── AppDelegate.m
├── CCTimePicker
├── UIView+CCUtil.h
├── NSDate+CCUtil.h
├── NSDate+CCUtil.m
├── vendor
│ └── JTCalendar
│ │ ├── JTCircleView.h
│ │ ├── JTCalendarMonthWeekDaysView.h
│ │ ├── JTCalendarMenuMonthView.h
│ │ ├── JTCalendarViewDataSource.h
│ │ ├── JTCalendarMonthView.h
│ │ ├── JTCalendarDayView.h
│ │ ├── JTCalendarMenuView.h
│ │ ├── JTCalendarWeekView.h
│ │ ├── JTCalendarContentView.h
│ │ ├── JTCalendar.h
│ │ ├── JTCircleView.m
│ │ ├── JTCalendarMenuMonthView.m
│ │ ├── JTCalendarAppearance.h
│ │ ├── JTCalendarWeekView.m
│ │ ├── JTCalendarAppearance.m
│ │ ├── JTCalendarMonthWeekDaysView.m
│ │ ├── JTCalendarMonthView.m
│ │ ├── JTCalendarMenuView.m
│ │ └── JTCalendar.m
├── CCHourCircleSlider.h
├── CCYearPickerView.h
├── UIView+CCUtil.m
├── CCMiniteCircleSlider.h
├── CCMinitePickerView.h
├── CCDatePickerView.h
├── CCTimePickerView.h
├── CCHourPickerView.h
├── CCDatePickerView.m
├── CCYearPickerView.xib
├── CCYearPickerView.m
├── CCMinitePickerView.m
├── CCHourPickerView.m
└── CCDatePickerView.xib
├── CCTimePickerDemoTests
├── Info.plist
└── CCTimePickerDemoTests.m
├── CCTimePickerDemoUITests
├── Info.plist
└── CCTimePickerDemoUITests.m
├── README.md
└── LICENSE
/gif/CCTimePickerGIF.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brefchan/CCTimePickerDemo/HEAD/gif/CCTimePickerGIF.gif
--------------------------------------------------------------------------------
/CCTimePickerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CCTimePickerDemo.xcodeproj/project.xcworkspace/xcuserdata/ehome.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/brefchan/CCTimePickerDemo/HEAD/CCTimePickerDemo.xcodeproj/project.xcworkspace/xcuserdata/ehome.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CCTimePickerDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/CCTimePicker/UIView+CCUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+CCUtil.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIView (CCUtil)
12 |
13 | + (instancetype)viewFromXib;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCircleView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCircleView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @interface JTCircleView : UIView
11 |
12 | @property (nonatomic, strong) UIColor *color;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/CCTimePicker/NSDate+CCUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+CCUtil.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/4/1.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDate (CCUtil)
12 | - (NSString *)dateToString:(NSString *)format;
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASLayoutConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASLayoutConstraint.h"
10 |
11 | @implementation MASLayoutConstraint
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarDataCache.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarDataCache.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @interface JTCalendarDataCache : NSObject
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | - (void)reloadData;
17 | - (BOOL)haveEvent:(NSDate *)date;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/NSDate+CCUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+CCUtil.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/4/1.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSDate (CCUtil)
12 |
13 |
14 | - (NSString *)stringForDateWithFormat:(NSString *)format;
15 |
16 | + (NSDate *)dateWithDateString:(NSString *)dateString format:(NSString *)dateFormat;
17 |
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMenuView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @interface JTCalendarMenuView : UIScrollView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (strong, nonatomic) NSDate *currentDate;
17 |
18 | - (void)reloadAppearance;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMonthWeekDaysView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthWeekDaysView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarMonthWeekDaysView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | + (void)beforeReloadAppearance;
17 | - (void)reloadAppearance;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/NSLayoutConstraint+MASDebugAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * makes debug and log output of NSLayoutConstraints more readable
13 | */
14 | @interface NSLayoutConstraint (MASDebugAdditions)
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMenuMonthView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuMonthView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarMenuMonthView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | - (void)setCurrentDate:(NSDate *)currentDate;
17 |
18 | - (void)reloadAppearance;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMonthView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarMonthView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | - (void)setBeginningOfMonth:(NSDate *)date;
17 | - (void)reloadData;
18 | - (void)reloadAppearance;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/CCTimePicker/NSDate+CCUtil.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+CCUtil.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/4/1.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "NSDate+CCUtil.h"
10 |
11 | @implementation NSDate (CCUtil)
12 | - (NSString *)dateToString:(NSString *)format
13 | {
14 | NSDateFormatter *dateFormater = [[NSDateFormatter alloc] init];
15 | [dateFormater setDateFormat:format];
16 | return [dateFormater stringFromDate:self];
17 | }
18 | @end
19 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarContentView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarContentView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @interface JTCalendarContentView : UIScrollView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (strong, nonatomic) NSDate *currentDate;
17 |
18 | - (void)reloadData;
19 | - (void)reloadAppearance;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarDayView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarDayView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarDayView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (strong, nonatomic) NSDate *date;
17 | @property (assign, nonatomic) BOOL isOtherMonth;
18 |
19 | - (void)reloadData;
20 | - (void)reloadAppearance;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarWeekView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarWeekView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarWeekView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (assign, nonatomic) NSUInteger currentMonthIndex;
17 |
18 | - (void)setBeginningOfWeek:(NSDate *)date;
19 | - (void)reloadData;
20 | - (void)reloadAppearance;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarViewDataSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarDataSource.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @protocol JTCalendarDataSource
13 |
14 | - (BOOL)calendarHaveEvent:(JTCalendar *)calendar date:(NSDate *)date;
15 | - (void)calendarDidDateSelected:(JTCalendar *)calendar date:(NSDate *)date;
16 |
17 | @optional
18 | - (void)calendarDidLoadPreviousPage;
19 | - (void)calendarDidLoadNextPage;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCircleView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCircleView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @interface JTCircleView : UIView
11 |
12 | @property (nonatomic, strong) UIColor *color;
13 |
14 | @end
15 |
16 | // 版权属于原作者
17 | // http://code4app.com (cn) http://code4app.net (en)
18 | // 发布代码于最专业的源码分享网站: Code4App.com
19 |
20 | // 版权属于原作者
21 | // http://code4app.com (cn) http://code4app.net (en)
22 | // 发布代码于最专业的源码分享网站: Code4App.com
23 |
24 | // 版权属于原作者
25 | // http://code4app.com (cn) http://code4app.net (en)
26 | // 发布代码于最专业的源码分享网站: Code4App.com
27 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASLayoutConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASLayoutConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * When you are debugging or printing the constraints attached to a view this subclass
13 | * makes it easier to identify which constraints have been created via Masonry
14 | */
15 | @interface MASLayoutConstraint : NSLayoutConstraint
16 |
17 | /**
18 | * a key to associate with this constraint
19 | */
20 | @property (nonatomic, strong) id mas_key;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASCompositeConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | /**
13 | * A group of MASConstraint objects
14 | */
15 | @interface MASCompositeConstraint : MASConstraint
16 |
17 | /**
18 | * Creates a composite with a predefined array of children
19 | *
20 | * @param children child MASConstraints
21 | *
22 | * @return a composite constraint
23 | */
24 | - (id)initWithChildren:(NSArray *)children;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CCTimePicker/CCHourCircleSlider.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCHourCircleSlider.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CCHourCircleSlider : UIControl
12 |
13 | @property (nonatomic, assign) CGFloat lineWidth;
14 | @property (nonatomic, strong) UIColor *selectColor;
15 | @property (nonatomic, strong) UIColor *unselectColor;
16 | @property (nonatomic, strong) UIColor *indicatorColor;
17 | @property (nonatomic, assign) CGFloat contextPadding;
18 |
19 | @property (nonatomic, assign) NSInteger angle;
20 |
21 | @property (nonatomic, assign) NSInteger hour;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCHourCircleSlider.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCHourCircleSlider.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CCHourCircleSlider : UIControl
12 |
13 | @property (nonatomic, assign) CGFloat circleWidth;
14 | @property (nonatomic, strong) UIColor *selectColor;
15 | @property (nonatomic, strong) UIColor *unselectColor;
16 | @property (nonatomic, strong) UIColor *indicatorColor;
17 | @property (nonatomic, assign) CGFloat contextPadding;
18 |
19 | @property (nonatomic, assign) NSInteger angle;
20 |
21 | @property (nonatomic, assign) NSInteger hour;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/UIView+CCUtil.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+CCUtil.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface UIView (CCUtil)
12 |
13 | @property(nonatomic,assign) CGPoint origin;
14 | @property(nonatomic,assign) CGFloat originX;
15 | @property(nonatomic,assign) CGFloat originY;
16 | @property(nonatomic,assign) CGSize size;
17 | @property(nonatomic,assign) CGFloat sizeW;
18 | @property(nonatomic,assign) CGFloat sizeH;
19 | @property(nonatomic,assign) CGFloat centerX;
20 | @property(nonatomic,assign) CGFloat centerY;
21 |
22 | + (instancetype)viewFromXib;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/CCTimePicker/CCYearPickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCYearPickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | @class CCYearPickerView;
11 |
12 | @protocol CCYearPickerViewDelegate
13 |
14 | @optional
15 | - (void)yearPikcerView:(CCYearPickerView *)pickerView didSelectYear:(NSString *)year;
16 |
17 | @end
18 |
19 | @interface CCYearPickerView : UIView
20 | <
21 | UIPickerViewDelegate,
22 | UIPickerViewDataSource
23 | >
24 |
25 | @property (weak, nonatomic) IBOutlet UIPickerView *yearPickerView;
26 |
27 | @property (nonatomic, weak) id delegate;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CCTimePicker/UIView+CCUtil.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+CCUtil.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "UIView+CCUtil.h"
10 |
11 | @implementation UIView (CCUtil)
12 |
13 | + (instancetype)viewFromXib
14 | {
15 | Class viewClass = [self class];
16 | NSString *viewClassName = NSStringFromClass(viewClass);
17 | NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:viewClassName owner:nil options:nil];
18 |
19 | for (id nibItem in nibArray) {
20 | if ([nibItem isMemberOfClass:viewClass]) {
21 | return nibItem;
22 | }
23 | }
24 |
25 | return nil;
26 | }
27 |
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCYearPickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCYearPickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | @class CCYearPickerView;
11 |
12 | @protocol CCYearPickerViewDelegate
13 |
14 | @optional
15 | - (void)yearPikcerView:(CCYearPickerView *)pickerView didSelectYear:(NSString *)year;
16 |
17 | @end
18 |
19 | @interface CCYearPickerView : UIView
20 | <
21 | UIPickerViewDelegate,
22 | UIPickerViewDataSource
23 | >
24 |
25 | @property (weak, nonatomic) IBOutlet UIPickerView *yearPickerView;
26 |
27 | @property (nonatomic, weak) id delegate;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/CCTimePicker/CCMiniteCircleSlider.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCMiniteCircleSlider.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CCMiniteCircleSlider : UIControl
12 |
13 | @property (nonatomic, assign) CGFloat lineWidth;
14 | @property (nonatomic, strong) UIColor *selectColor;
15 | @property (nonatomic, strong) UIColor *unselectColor;
16 | @property (nonatomic, strong) UIColor *indicatorColor;
17 | @property (nonatomic, assign) CGFloat contextPadding;
18 |
19 | @property (nonatomic, assign) NSInteger angle;
20 |
21 | @property (nonatomic, assign) NSInteger value;
22 |
23 | @property (nonatomic, assign) NSInteger minite;
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCMiniteCircleSlider.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCMiniteCircleSlider.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CCMiniteCircleSlider : UIControl
12 |
13 | @property (nonatomic, assign) CGFloat lineWidth;
14 | @property (nonatomic, strong) UIColor *selectColor;
15 | @property (nonatomic, strong) UIColor *unselectColor;
16 | @property (nonatomic, strong) UIColor *indicatorColor;
17 | @property (nonatomic, assign) CGFloat contextPadding;
18 |
19 | @property (nonatomic, assign) NSInteger angle;
20 |
21 | @property (nonatomic, assign) NSInteger value;
22 |
23 | @property (nonatomic, assign) NSInteger minite;
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/CCTimePickerDemoTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMonthWeekDaysView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthWeekDaysView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarMonthWeekDaysView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | + (void)beforeReloadAppearance;
17 | - (void)reloadAppearance;
18 |
19 | @end
20 |
21 | // 版权属于原作者
22 | // http://code4app.com (cn) http://code4app.net (en)
23 | // 发布代码于最专业的源码分享网站: Code4App.com
24 |
25 | // 版权属于原作者
26 | // http://code4app.com (cn) http://code4app.net (en)
27 | // 发布代码于最专业的源码分享网站: Code4App.com
28 |
29 | // 版权属于原作者
30 | // http://code4app.com (cn) http://code4app.net (en)
31 | // 发布代码于最专业的源码分享网站: Code4App.com
32 |
--------------------------------------------------------------------------------
/CCTimePickerDemoUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CCTimePicker/CCMinitePickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCMinitePickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | @class CCMinitePickerView;
11 |
12 | @protocol CCMinitePickerViewDelegate
13 |
14 | @optional
15 |
16 | - (void)minitePickerView:(CCMinitePickerView *)pickerView miniteSelectEnd:(NSString *)minite;
17 |
18 | - (void)minitePickerView:(CCMinitePickerView *)pickerView didSelectMinite:(NSString *)minite;
19 |
20 | @end
21 |
22 | @interface CCMinitePickerView : UIView
23 |
24 | @property (nonatomic, weak) id delegate;
25 |
26 | @property (nonatomic, assign) NSInteger minite;
27 |
28 | - (void)setMiniteWithDate:(NSDate *)date;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMenuMonthView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuMonthView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarMenuMonthView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | - (void)setMonthIndex:(NSInteger)monthIndex;
17 |
18 | - (void)reloadAppearance;
19 |
20 | @end
21 |
22 | // 版权属于原作者
23 | // http://code4app.com (cn) http://code4app.net (en)
24 | // 发布代码于最专业的源码分享网站: Code4App.com
25 |
26 | // 版权属于原作者
27 | // http://code4app.com (cn) http://code4app.net (en)
28 | // 发布代码于最专业的源码分享网站: Code4App.com
29 |
30 | // 版权属于原作者
31 | // http://code4app.com (cn) http://code4app.net (en)
32 | // 发布代码于最专业的源码分享网站: Code4App.com
33 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarViewDataSource.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarDataSource.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @protocol JTCalendarDataSource
13 |
14 | - (BOOL)calendarHaveEvent:(JTCalendar *)calendar date:(NSDate *)date;
15 | - (void)calendarDidDateSelected:(JTCalendar *)calendar date:(NSDate *)date;
16 |
17 | @end
18 |
19 | // 版权属于原作者
20 | // http://code4app.com (cn) http://code4app.net (en)
21 | // 发布代码于最专业的源码分享网站: Code4App.com
22 |
23 | // 版权属于原作者
24 | // http://code4app.com (cn) http://code4app.net (en)
25 | // 发布代码于最专业的源码分享网站: Code4App.com
26 |
27 | // 版权属于原作者
28 | // http://code4app.com (cn) http://code4app.net (en)
29 | // 发布代码于最专业的源码分享网站: Code4App.com
30 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMonthView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarMonthView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | - (void)setBeginningOfMonth:(NSDate *)date;
17 | - (void)reloadData;
18 | - (void)reloadAppearance;
19 |
20 | @end
21 |
22 | // 版权属于原作者
23 | // http://code4app.com (cn) http://code4app.net (en)
24 | // 发布代码于最专业的源码分享网站: Code4App.com
25 |
26 | // 版权属于原作者
27 | // http://code4app.com (cn) http://code4app.net (en)
28 | // 发布代码于最专业的源码分享网站: Code4App.com
29 |
30 | // 版权属于原作者
31 | // http://code4app.com (cn) http://code4app.net (en)
32 | // 发布代码于最专业的源码分享网站: Code4App.com
33 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCMinitePickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCMinitePickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | @class CCMinitePickerView;
11 |
12 | @protocol CCMinitePickerViewDelegate
13 |
14 | @optional
15 |
16 | - (void)minitePickerView:(CCMinitePickerView *)pickerView miniteSelectEnd:(NSString *)minite;
17 |
18 | - (void)minitePickerView:(CCMinitePickerView *)pickerView didSelectMinite:(NSString *)minite;
19 |
20 | @end
21 |
22 | @interface CCMinitePickerView : UIView
23 |
24 | @property (nonatomic, weak) id delegate;
25 |
26 | @property (nonatomic, assign) NSInteger minite;
27 |
28 | - (void)setMiniteWithDate:(NSDate *)date;
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CCTimePickerDemo
2 | 时间选择器的另一种样子
3 |
4 | #### 如果觉得有用,不妨给个Star呗~
5 |
6 | ### 项目演示
7 | 
8 |
9 | ### 使用方法
10 |
11 | 将CCTimePicker文件夹导入项目.
12 |
13 | ```
14 | - (void)showTimePickerView{
15 | CCTimePickerView *pickerView = [CCTimePickerView viewFromXib];
16 | pickerView.delegate = self;
17 | pickerView.isAutoNext = YES;
18 | [pickerView setCurrentDate:[NSDate date]];
19 |
20 | [self.pickerView popInView:self.view];
21 | }
22 |
23 | #pragma mark CCTimePickerViewDelegate
24 | - (void)pickerView:(CCTimePickerView *)timePickerView didSelectTime:(NSDate *)date
25 | {
26 | NSLog(@"%@",date);
27 | }
28 |
29 | - (void)pickerViewCancelSelect:(CCTimePickerView *)timePickerView
30 | {
31 | NSLog(@"取消");
32 | }
33 | ```
34 |
35 |
36 |
--------------------------------------------------------------------------------
/CCTimePicker/CCDatePickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCDatePickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "JTCalendar.h"
11 | @class CCDatePickerView;
12 |
13 | @protocol CCDatePickerViewDelegate
14 |
15 | @optional
16 | - (void)datePickerView:(CCDatePickerView *)pickerView didSelectDate:(NSDate *)date;
17 |
18 | @end
19 |
20 |
21 | @interface CCDatePickerView : UIView
22 | <
23 | JTCalendarDataSource
24 | >
25 |
26 | @property (nonatomic, weak) IBOutlet JTCalendarMenuView *menuView;
27 | @property (nonatomic, weak) IBOutlet JTCalendarContentView *contentView;
28 | @property (nonatomic, strong) JTCalendar *calendar;
29 |
30 | @property (nonatomic, weak) id delegate;
31 |
32 |
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarDayView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarDayView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarDayView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (strong, nonatomic) NSDate *date;
17 | @property (assign, nonatomic) BOOL isOtherMonth;
18 |
19 | - (void)reloadData;
20 | - (void)reloadAppearance;
21 |
22 | @end
23 |
24 | // 版权属于原作者
25 | // http://code4app.com (cn) http://code4app.net (en)
26 | // 发布代码于最专业的源码分享网站: Code4App.com
27 |
28 | // 版权属于原作者
29 | // http://code4app.com (cn) http://code4app.net (en)
30 | // 发布代码于最专业的源码分享网站: Code4App.com
31 |
32 | // 版权属于原作者
33 | // http://code4app.com (cn) http://code4app.net (en)
34 | // 发布代码于最专业的源码分享网站: Code4App.com
35 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMenuView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @interface JTCalendarMenuView : UIScrollView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (strong, nonatomic) NSDate *currentDate;
17 |
18 | - (void)loadPreviousMonth;
19 | - (void)loadNextMonth;
20 |
21 | - (void)reloadAppearance;
22 |
23 | @end
24 |
25 | // 版权属于原作者
26 | // http://code4app.com (cn) http://code4app.net (en)
27 | // 发布代码于最专业的源码分享网站: Code4App.com
28 |
29 | // 版权属于原作者
30 | // http://code4app.com (cn) http://code4app.net (en)
31 | // 发布代码于最专业的源码分享网站: Code4App.com
32 |
33 | // 版权属于原作者
34 | // http://code4app.com (cn) http://code4app.net (en)
35 | // 发布代码于最专业的源码分享网站: Code4App.com
36 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarWeekView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarWeekView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarWeekView : UIView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (assign, nonatomic) NSUInteger currentMonthIndex;
17 |
18 | - (void)setBeginningOfWeek:(NSDate *)date;
19 | - (void)reloadData;
20 | - (void)reloadAppearance;
21 |
22 | @end
23 |
24 | // 版权属于原作者
25 | // http://code4app.com (cn) http://code4app.net (en)
26 | // 发布代码于最专业的源码分享网站: Code4App.com
27 |
28 | // 版权属于原作者
29 | // http://code4app.com (cn) http://code4app.net (en)
30 | // 发布代码于最专业的源码分享网站: Code4App.com
31 |
32 | // 版权属于原作者
33 | // http://code4app.com (cn) http://code4app.net (en)
34 | // 发布代码于最专业的源码分享网站: Code4App.com
35 |
--------------------------------------------------------------------------------
/CCTimePickerDemo.xcodeproj/xcuserdata/ehome.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CCTimePickerDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 9A6332281E8CDE9200D4B11A
16 |
17 | primary
18 |
19 |
20 | 9A6332411E8CDE9200D4B11A
21 |
22 | primary
23 |
24 |
25 | 9A63324C1E8CDE9200D4B11A
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarContentView.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarContentView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @interface JTCalendarContentView : UIScrollView
13 |
14 | @property (weak, nonatomic) JTCalendar *calendarManager;
15 |
16 | @property (strong, nonatomic) NSDate *currentDate;
17 |
18 | - (void)loadPreviousMonth;
19 | - (void)loadNextMonth;
20 |
21 | - (void)reloadData;
22 | - (void)reloadAppearance;
23 |
24 | @end
25 |
26 | // 版权属于原作者
27 | // http://code4app.com (cn) http://code4app.net (en)
28 | // 发布代码于最专业的源码分享网站: Code4App.com
29 |
30 | // 版权属于原作者
31 | // http://code4app.com (cn) http://code4app.net (en)
32 | // 发布代码于最专业的源码分享网站: Code4App.com
33 |
34 | // 版权属于原作者
35 | // http://code4app.com (cn) http://code4app.net (en)
36 | // 发布代码于最专业的源码分享网站: Code4App.com
37 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCDatePickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCDatePickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "JTCalendar.h"
11 | @class CCDatePickerView;
12 |
13 | @protocol CCDatePickerViewDelegate
14 |
15 | @optional
16 | - (void)datePickerView:(CCDatePickerView *)pickerView didSelectDate:(NSDate *)date;
17 |
18 | @end
19 |
20 |
21 | @interface CCDatePickerView : UIView
22 | <
23 | JTCalendarDataSource
24 | >
25 |
26 | @property (nonatomic, weak) IBOutlet JTCalendarMenuView *menuView;
27 | @property (nonatomic, weak) IBOutlet JTCalendarContentView *contentView;
28 | @property (nonatomic, strong) JTCalendar *calendar;
29 |
30 | @property (nonatomic, weak) id delegate;
31 |
32 | - (void)setSelectDate:(NSDate *)date;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/CCTimePicker/CCTimePickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCTimePickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef NS_ENUM(NSUInteger,CCTimePickerState) {
12 | CCTimePickerStateNone,
13 | CCTimePickerStateYear,
14 | CCTimePickerStateTime,
15 | CCTimePickerStateHour,
16 | CCTimePickerStateMinite
17 | };
18 |
19 | @interface CCTimePickerView : UIView
20 |
21 | @property (weak, nonatomic) IBOutlet UIButton *yearButton;
22 | @property (weak, nonatomic) IBOutlet UIButton *timeButton;
23 | @property (weak, nonatomic) IBOutlet UIView *hourAndMiniteView;
24 | @property (weak, nonatomic) IBOutlet UIButton *hourButton;
25 | @property (weak, nonatomic) IBOutlet UIButton *miniteButton;
26 |
27 | @property (nonatomic, assign) CCTimePickerState state;
28 |
29 | - (void)setCurrentDate:(NSDate *)date;
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/Masonry.h:
--------------------------------------------------------------------------------
1 | //
2 | // Masonry.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for Masonry.
12 | FOUNDATION_EXPORT double MasonryVersionNumber;
13 |
14 | //! Project version string for Masonry.
15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
16 |
17 | #import "MASUtilities.h"
18 | #import "View+MASAdditions.h"
19 | #import "View+MASShorthandAdditions.h"
20 | #import "ViewController+MASAdditions.h"
21 | #import "NSArray+MASAdditions.h"
22 | #import "NSArray+MASShorthandAdditions.h"
23 | #import "MASConstraint.h"
24 | #import "MASCompositeConstraint.h"
25 | #import "MASViewAttribute.h"
26 | #import "MASViewConstraint.h"
27 | #import "MASConstraintMaker.h"
28 | #import "MASLayoutConstraint.h"
29 | #import "NSLayoutConstraint+MASDebugAdditions.h"
30 |
--------------------------------------------------------------------------------
/CCTimePicker/CCHourPickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCHourPickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | @class CCHourPickerView;
11 |
12 | typedef NS_ENUM(NSInteger,CCHourPickerViewState) {
13 | CCHourPickerViewStateAM, //上午
14 | CCHourPickerViewStatePM //下午
15 | };
16 |
17 | @protocol CCHourPickerViewDelegate
18 |
19 | @optional
20 | - (void)hourPickerView:(CCHourPickerView *)pickerView didSelectHour:(NSString *)hour;
21 |
22 | - (void)hourPickerView:(CCHourPickerView *)pickerView hourSelectEnd:(NSString *)hour;
23 |
24 | @end
25 |
26 | @interface CCHourPickerView : UIView
27 |
28 | @property (nonatomic, weak) id delegate;
29 |
30 | @property (nonatomic, assign) CCHourPickerViewState state;
31 | @property (nonatomic, assign) NSInteger hour;
32 |
33 | - (void)setHourWithDate:(NSDate *)date;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCHourPickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCHourPickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 | @class CCHourPickerView;
11 |
12 | typedef NS_ENUM(NSInteger,CCHourPickerViewState) {
13 | CCHourPickerViewStateAM, //上午
14 | CCHourPickerViewStatePM //下午
15 | };
16 |
17 | @protocol CCHourPickerViewDelegate
18 |
19 | @optional
20 | - (void)hourPickerView:(CCHourPickerView *)pickerView didSelectHour:(NSString *)hour;
21 |
22 | - (void)hourPickerView:(CCHourPickerView *)pickerView hourSelectEnd:(NSString *)hour;
23 |
24 | @end
25 |
26 | @interface CCHourPickerView : UIView
27 |
28 | @property (nonatomic, weak) id delegate;
29 |
30 | @property (nonatomic, assign) CCHourPickerViewState state;
31 | @property (nonatomic, assign) NSInteger hour;
32 |
33 | - (void)setHourWithDate:(NSDate *)date;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/ViewController+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | #ifdef MAS_VIEW_CONTROLLER
14 |
15 | @interface MAS_VIEW_CONTROLLER (MASAdditions)
16 |
17 | /**
18 | * following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute
19 | */
20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom;
26 |
27 |
28 | @end
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCTimePickerView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CCTimePickerView.h
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef NS_ENUM(NSUInteger,CCTimePickerState) {
12 | CCTimePickerStateNone,
13 | CCTimePickerStateYear,
14 | CCTimePickerStateTime,
15 | CCTimePickerStateHour,
16 | CCTimePickerStateMinite
17 | };
18 |
19 | @class CCTimePickerView;
20 |
21 | @protocol CCTimePickerViewDelegage
22 |
23 | @optional
24 | - (void)pickerView:(CCTimePickerView *)timePickerView didSelectTime:(NSDate *)date;
25 |
26 | - (void)pickerViewCancelSelect:(CCTimePickerView *)timePickerView;
27 |
28 | @end
29 |
30 |
31 | @interface CCTimePickerView : UIView
32 |
33 | @property (nonatomic, assign) CCTimePickerState state;
34 |
35 | //是否自动跳转下一步
36 | @property (nonatomic, assign) BOOL isAutoNext;
37 |
38 | @property (nonatomic, weak) id delegate;
39 |
40 | - (void)setCurrentDate:(NSDate *)date;
41 |
42 | - (void)popInView:(UIView *)view;
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/CCTimePickerDemoTests/CCTimePickerDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCTimePickerDemoTests.m
3 | // CCTimePickerDemoTests
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CCTimePickerDemoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CCTimePickerDemoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 bref-Chan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/NSArray+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSArray+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand array additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface NSArray (MASShorthandAdditions)
18 |
19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
22 |
23 | @end
24 |
25 | @implementation NSArray (MASShorthandAdditions)
26 |
27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
28 | return [self mas_makeConstraints:block];
29 | }
30 |
31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
32 | return [self mas_updateConstraints:block];
33 | }
34 |
35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
36 | return [self mas_remakeConstraints:block];
37 | }
38 |
39 | @end
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendar.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendar.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendarViewDataSource.h"
11 | #import "JTCalendarAppearance.h"
12 |
13 | #import "JTCalendarMenuView.h"
14 | #import "JTCalendarContentView.h"
15 |
16 | @interface JTCalendar : NSObject
17 |
18 | @property (weak, nonatomic) JTCalendarMenuView *menuMonthsView;
19 | @property (weak, nonatomic) JTCalendarContentView *contentView;
20 |
21 | @property (weak, nonatomic) id dataSource;
22 |
23 | @property (strong, nonatomic) NSDate *currentDate;
24 | @property (strong, nonatomic) NSDate *currentDateSelected;
25 |
26 | - (JTCalendarAppearance *)calendarAppearance;
27 |
28 | - (void)reloadData;
29 | - (void)reloadAppearance;
30 |
31 | - (void)loadPreviousMonth;
32 | - (void)loadNextMonth;
33 |
34 | @end
35 |
36 | // 版权属于原作者
37 | // http://code4app.com (cn) http://code4app.net (en)
38 | // 发布代码于最专业的源码分享网站: Code4App.com
39 |
40 | // 版权属于原作者
41 | // http://code4app.com (cn) http://code4app.net (en)
42 | // 发布代码于最专业的源码分享网站: Code4App.com
43 |
44 | // 版权属于原作者
45 | // http://code4app.com (cn) http://code4app.net (en)
46 | // 发布代码于最专业的源码分享网站: Code4App.com
47 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCircleView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCircleView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCircleView.h"
9 |
10 | // http://stackoverflow.com/questions/17038017/ios-draw-filled-circles
11 |
12 | @implementation JTCircleView
13 |
14 | - (instancetype)init
15 | {
16 | self = [super init];
17 | if(!self){
18 | return nil;
19 | }
20 |
21 | self.backgroundColor = [UIColor clearColor];
22 | self.color = [UIColor whiteColor];
23 |
24 | return self;
25 | }
26 |
27 |
28 | - (void)drawRect:(CGRect)rect
29 | {
30 | CGContextRef ctx = UIGraphicsGetCurrentContext();
31 |
32 | CGContextSetFillColorWithColor(ctx, [self.backgroundColor CGColor]);
33 | CGContextFillRect(ctx, rect);
34 |
35 | rect = CGRectInset(rect, .5, .5);
36 |
37 | CGContextSetStrokeColorWithColor(ctx, [self.color CGColor]);
38 | CGContextSetFillColorWithColor(ctx, [self.color CGColor]);
39 |
40 | CGContextAddEllipseInRect(ctx, rect);
41 | CGContextFillEllipseInRect(ctx, rect);
42 |
43 | CGContextFillPath(ctx);
44 | }
45 |
46 | - (void)setColor:(UIColor *)color
47 | {
48 | self->_color = color;
49 |
50 | [self setNeedsDisplay];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/NSDate+CCUtil.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSDate+CCUtil.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/4/1.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "NSDate+CCUtil.h"
10 | #import
11 |
12 | @implementation NSDate (CCUtil)
13 |
14 | static NSString *formatterKey = @"formatterKey";
15 |
16 | + (NSDateFormatter *)formatter
17 | {
18 | NSDateFormatter *formatter = objc_getAssociatedObject(self, &formatterKey);
19 |
20 | if (!formatter) {
21 | formatter = [[NSDateFormatter alloc] init];
22 | objc_setAssociatedObject(self, &formatterKey,formatter, OBJC_ASSOCIATION_COPY_NONATOMIC);
23 | }
24 |
25 | return objc_getAssociatedObject(self, &formatterKey);
26 | }
27 |
28 |
29 | - (NSString *)stringForDateWithFormat:(NSString *)format
30 | {
31 | NSDateFormatter *dateFormater = [NSDate formatter];
32 | [dateFormater setDateFormat:format];
33 | return [dateFormater stringFromDate:self];
34 | }
35 |
36 | + (NSDate *)dateWithDateString:(NSString *)dateString format:(NSString *)dateFormat
37 | {
38 | NSDateFormatter *dateFormater = [NSDate formatter];
39 | [dateFormater setDateFormat:dateFormat];
40 | return [dateFormater dateFromString:dateString];
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendar.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendar.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | #import "JTCalendarViewDataSource.h"
11 | #import "JTCalendarAppearance.h"
12 |
13 | #import "JTCalendarMenuView.h"
14 | #import "JTCalendarContentView.h"
15 |
16 | #import "JTCalendarDataCache.h"
17 |
18 | @interface JTCalendar : NSObject
19 |
20 | @property (weak, nonatomic) JTCalendarMenuView *menuMonthsView;
21 | @property (weak, nonatomic) JTCalendarContentView *contentView;
22 |
23 | @property (weak, nonatomic) id dataSource;
24 |
25 | @property (strong, nonatomic) NSDate *currentDate;
26 | @property (strong, nonatomic) NSDate *currentDateSelected;
27 |
28 | @property (strong, nonatomic, readonly) JTCalendarDataCache *dataCache;
29 | @property (strong, nonatomic, readonly) JTCalendarAppearance *calendarAppearance;
30 |
31 | - (void)reloadData;
32 | - (void)reloadAppearance;
33 |
34 | - (void)loadPreviousMonth DEPRECATED_MSG_ATTRIBUTE("Use loadPreviousPage instead");
35 | - (void)loadNextMonth DEPRECATED_MSG_ATTRIBUTE("Use loadNextPage instead");
36 |
37 | - (void)loadPreviousPage;
38 | - (void)loadNextPage;
39 |
40 | - (void)repositionViews;
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCircleView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCircleView.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCircleView.h"
9 |
10 | // http://stackoverflow.com/questions/17038017/ios-draw-filled-circles
11 |
12 | @implementation JTCircleView
13 |
14 | - (instancetype)init
15 | {
16 | self = [super init];
17 | if(!self){
18 | return nil;
19 | }
20 |
21 | self.backgroundColor = [UIColor clearColor];
22 | self.color = [UIColor whiteColor];
23 |
24 | return self;
25 | }
26 |
27 |
28 | - (void)drawRect:(CGRect)rect
29 | {
30 | CGContextRef ctx = UIGraphicsGetCurrentContext();
31 |
32 | CGContextSetFillColorWithColor(ctx, [self.backgroundColor CGColor]);
33 | CGContextFillRect(ctx, rect);
34 |
35 | rect = CGRectInset(rect, .5, .5);
36 |
37 | CGContextSetStrokeColorWithColor(ctx, [self.color CGColor]);
38 | CGContextSetFillColorWithColor(ctx, [self.color CGColor]);
39 |
40 | CGContextAddEllipseInRect(ctx, rect);
41 | CGContextFillEllipseInRect(ctx, rect);
42 |
43 | CGContextFillPath(ctx);
44 | }
45 |
46 | - (void)setColor:(UIColor *)color
47 | {
48 | self->_color = color;
49 |
50 | [self setNeedsDisplay];
51 | }
52 |
53 | @end
54 |
55 | // 版权属于原作者
56 | // http://code4app.com (cn) http://code4app.net (en)
57 | // 发布代码于最专业的源码分享网站: Code4App.com
58 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/CCTimePickerDemoUITests/CCTimePickerDemoUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCTimePickerDemoUITests.m
3 | // CCTimePickerDemoUITests
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CCTimePickerDemoUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation CCTimePickerDemoUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/CCTimePicker/CCDatePickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCDatePickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCDatePickerView.h"
10 |
11 | @implementation CCDatePickerView
12 |
13 | - (void)awakeFromNib
14 | {
15 | [super awakeFromNib];
16 |
17 | self.backgroundColor = [UIColor clearColor];
18 | [self.calendar reloadData];
19 | }
20 |
21 | #pragma mark - JTCalendarDataSource
22 |
23 | - (BOOL)calendarHaveEvent:(JTCalendar *)calendar date:(NSDate *)date
24 | {
25 | return NO;
26 | }
27 |
28 | - (void)calendarDidDateSelected:(JTCalendar *)calendar date:(NSDate *)date
29 | {
30 | if (self.delegate && [self.delegate respondsToSelector:@selector(datePickerView:didSelectDate:)]) {
31 | [self.delegate datePickerView:self didSelectDate:date];
32 | }
33 | }
34 |
35 | #pragma mark - Getter & Setter
36 | - (JTCalendar *)calendar
37 | {
38 | if (!_calendar) {
39 | _calendar = [JTCalendar new];
40 | _calendar.calendarAppearance.calendar.firstWeekday = 2;
41 | _calendar.calendarAppearance.dayCircleRatio = 9. / 10.;
42 | _calendar.calendarAppearance.ratioContentMenu = 1.;
43 | [_calendar setMenuMonthsView:self.menuView];
44 | [_calendar setContentView:self.contentView];
45 | [_calendar setDataSource:self];
46 | }
47 | return _calendar;
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASViewAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 |
11 | @implementation MASViewAttribute
12 |
13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
15 | return self;
16 | }
17 |
18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
19 | self = [super init];
20 | if (!self) return nil;
21 |
22 | _view = view;
23 | _item = item;
24 | _layoutAttribute = layoutAttribute;
25 |
26 | return self;
27 | }
28 |
29 | - (BOOL)isSizeAttribute {
30 | return self.layoutAttribute == NSLayoutAttributeWidth
31 | || self.layoutAttribute == NSLayoutAttributeHeight;
32 | }
33 |
34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
35 | if ([viewAttribute isKindOfClass:self.class]) {
36 | return self.view == viewAttribute.view
37 | && self.layoutAttribute == viewAttribute.layoutAttribute;
38 | }
39 | return [super isEqual:viewAttribute];
40 | }
41 |
42 | - (NSUInteger)hash {
43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASViewAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASAttribute.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 |
11 | /**
12 | * An immutable tuple which stores the view and the related NSLayoutAttribute.
13 | * Describes part of either the left or right hand side of a constraint equation
14 | */
15 | @interface MASViewAttribute : NSObject
16 |
17 | /**
18 | * The view which the reciever relates to. Can be nil if item is not a view.
19 | */
20 | @property (nonatomic, weak, readonly) MAS_VIEW *view;
21 |
22 | /**
23 | * The item which the reciever relates to.
24 | */
25 | @property (nonatomic, weak, readonly) id item;
26 |
27 | /**
28 | * The attribute which the reciever relates to
29 | */
30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
31 |
32 | /**
33 | * Convenience initializer.
34 | */
35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
36 |
37 | /**
38 | * The designated initializer.
39 | */
40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
41 |
42 | /**
43 | * Determine whether the layoutAttribute is a size attribute
44 | *
45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
46 | */
47 | - (BOOL)isSizeAttribute;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "UIView+CCUtil.h"
11 | #import "CCDatePickerView.h"
12 | #import "CCTimePickerView.h"
13 |
14 | @interface ViewController ()
15 | <
16 | CCTimePickerViewDelegage
17 | >
18 |
19 | @property (nonatomic, strong) CCTimePickerView *pickerView;
20 |
21 | @end
22 |
23 | @implementation ViewController
24 |
25 | - (void)viewDidLoad {
26 | [super viewDidLoad];
27 | // Do any additional setup after loading the view, typically from a nib.
28 |
29 | self.pickerView = [CCTimePickerView viewFromXib];
30 | self.pickerView.delegate = self;
31 | self.pickerView.isAutoNext = YES;
32 | [self.pickerView setCurrentDate:[NSDate date]];
33 |
34 | }
35 |
36 | #pragma mark - Event
37 | - (IBAction)popButtonClick:(id)sender {
38 | [self.pickerView popInView:self.view];
39 | }
40 |
41 | #pragma mark - Delegate
42 | #pragma mark CCTimePickerViewDelegate
43 | - (void)pickerView:(CCTimePickerView *)timePickerView didSelectTime:(NSDate *)date
44 | {
45 | NSLog(@"%@",date);
46 | }
47 |
48 | - (void)pickerViewCancelSelect:(CCTimePickerView *)timePickerView
49 | {
50 | NSLog(@"取消");
51 | }
52 |
53 |
54 | - (void)didReceiveMemoryWarning {
55 | [super didReceiveMemoryWarning];
56 | // Dispose of any resources that can be recreated.
57 | }
58 |
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/ViewController+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIViewController+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Craig Siemens on 2015-06-23.
6 | //
7 | //
8 |
9 | #import "ViewController+MASAdditions.h"
10 |
11 | #ifdef MAS_VIEW_CONTROLLER
12 |
13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions)
14 |
15 | - (MASViewAttribute *)mas_topLayoutGuide {
16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
17 | }
18 | - (MASViewAttribute *)mas_topLayoutGuideTop {
19 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop];
20 | }
21 | - (MASViewAttribute *)mas_topLayoutGuideBottom {
22 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
23 | }
24 |
25 | - (MASViewAttribute *)mas_bottomLayoutGuide {
26 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
27 | }
28 | - (MASViewAttribute *)mas_bottomLayoutGuideTop {
29 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
30 | }
31 | - (MASViewAttribute *)mas_bottomLayoutGuideBottom {
32 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
33 | }
34 |
35 |
36 |
37 | @end
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASViewConstraint.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASViewAttribute.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 | #import "MASUtilities.h"
13 |
14 | /**
15 | * A single constraint.
16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
17 | */
18 | @interface MASViewConstraint : MASConstraint
19 |
20 | /**
21 | * First item/view and first attribute of the NSLayoutConstraint
22 | */
23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
24 |
25 | /**
26 | * Second item/view and second attribute of the NSLayoutConstraint
27 | */
28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
29 |
30 | /**
31 | * initialises the MASViewConstraint with the first part of the equation
32 | *
33 | * @param firstViewAttribute view.mas_left, view.mas_width etc.
34 | *
35 | * @return a new view constraint
36 | */
37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
38 |
39 | /**
40 | * Returns all MASViewConstraints installed with this view as a first item.
41 | *
42 | * @param view A view to retrieve constraints for.
43 | *
44 | * @return An array of MASViewConstraints.
45 | */
46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarDataCache.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarDataCache.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarDataCache.h"
9 |
10 | #import "JTCalendar.h"
11 |
12 | @interface JTCalendarDataCache(){
13 | NSMutableDictionary *events;
14 | NSDateFormatter *dateFormatter;
15 | };
16 |
17 | @end
18 |
19 | @implementation JTCalendarDataCache
20 |
21 | - (instancetype)init
22 | {
23 | self = [super init];
24 | if(!self){
25 | return nil;
26 | }
27 |
28 | dateFormatter = [NSDateFormatter new];
29 | [dateFormatter setDateFormat:@"yyyy-MM-dd"];
30 | events = [NSMutableDictionary new];
31 |
32 | return self;
33 | }
34 |
35 | - (void)reloadData
36 | {
37 | [events removeAllObjects];
38 | }
39 |
40 | - (BOOL)haveEvent:(NSDate *)date
41 | {
42 | if(!self.calendarManager.dataSource){
43 | return NO;
44 | }
45 |
46 | if(!self.calendarManager.calendarAppearance.useCacheSystem){
47 | return [self.calendarManager.dataSource calendarHaveEvent:self.calendarManager date:date];
48 | }
49 |
50 | BOOL haveEvent;
51 | NSString *key = [dateFormatter stringFromDate:date];
52 |
53 | if(events[key] != nil){
54 | haveEvent = [events[key] boolValue];
55 | }
56 | else{
57 | haveEvent = [self.calendarManager.dataSource calendarHaveEvent:self.calendarManager date:date];
58 | events[key] = [NSNumber numberWithBool:haveEvent];
59 | }
60 |
61 | return haveEvent;
62 | }
63 |
64 | @end
--------------------------------------------------------------------------------
/CCTimePickerDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMenuMonthView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuMonthView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMenuMonthView.h"
9 |
10 | @interface JTCalendarMenuMonthView(){
11 | UILabel *textLabel;
12 | }
13 |
14 | @end
15 |
16 | @implementation JTCalendarMenuMonthView
17 |
18 | - (instancetype)initWithFrame:(CGRect)frame
19 | {
20 | self = [super initWithFrame:frame];
21 | if(!self){
22 | return nil;
23 | }
24 |
25 | [self commonInit];
26 |
27 | return self;
28 | }
29 |
30 | - (id)initWithCoder:(NSCoder *)aDecoder
31 | {
32 | self = [super initWithCoder:aDecoder];
33 | if(!self){
34 | return nil;
35 | }
36 |
37 | [self commonInit];
38 |
39 | return self;
40 | }
41 |
42 | - (void)commonInit
43 | {
44 | {
45 | textLabel = [UILabel new];
46 | [self addSubview:textLabel];
47 |
48 | textLabel.textAlignment = NSTextAlignmentCenter;
49 | textLabel.numberOfLines = 0;
50 | }
51 | }
52 |
53 | - (void)setCurrentDate:(NSDate *)currentDate
54 | {
55 | textLabel.text = self.calendarManager.calendarAppearance.monthBlock(currentDate, self.calendarManager);
56 | }
57 |
58 | - (void)layoutSubviews
59 | {
60 | textLabel.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
61 |
62 | // No need to call [super layoutSubviews]
63 | }
64 |
65 | - (void)reloadAppearance
66 | {
67 | textLabel.textColor = self.calendarManager.calendarAppearance.menuMonthTextColor;
68 | textLabel.font = self.calendarManager.calendarAppearance.menuMonthTextFont;
69 | }
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMenuMonthView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuMonthView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMenuMonthView.h"
9 |
10 | @interface JTCalendarMenuMonthView(){
11 | UILabel *textLabel;
12 | }
13 |
14 | @end
15 |
16 | @implementation JTCalendarMenuMonthView
17 |
18 | - (instancetype)initWithFrame:(CGRect)frame
19 | {
20 | self = [super initWithFrame:frame];
21 | if(!self){
22 | return nil;
23 | }
24 |
25 | [self commonInit];
26 |
27 | return self;
28 | }
29 |
30 | - (id)initWithCoder:(NSCoder *)aDecoder
31 | {
32 | self = [super initWithCoder:aDecoder];
33 | if(!self){
34 | return nil;
35 | }
36 |
37 | [self commonInit];
38 |
39 | return self;
40 | }
41 |
42 | - (void)commonInit
43 | {
44 | {
45 | textLabel = [UILabel new];
46 | [self addSubview:textLabel];
47 |
48 | textLabel.textAlignment = NSTextAlignmentCenter;
49 | }
50 | }
51 |
52 | - (void)setMonthIndex:(NSInteger)monthIndex
53 | {
54 | static NSDateFormatter *dateFormatter;
55 | if(!dateFormatter){
56 | dateFormatter = [NSDateFormatter new];
57 | dateFormatter.timeZone = self.calendarManager.calendarAppearance.calendar.timeZone;
58 | }
59 |
60 | while(monthIndex <= 0){
61 | monthIndex += 12;
62 | }
63 |
64 | textLabel.text = [[dateFormatter standaloneMonthSymbols][monthIndex - 1] capitalizedString];
65 | }
66 |
67 | - (void)layoutSubviews
68 | {
69 | textLabel.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
70 |
71 | // No need to call [super layoutSubviews]
72 | }
73 |
74 | - (void)reloadAppearance
75 | {
76 | textLabel.textColor = self.calendarManager.calendarAppearance.menuMonthTextColor;
77 | textLabel.font = self.calendarManager.calendarAppearance.menuMonthTextFont;
78 | }
79 |
80 | @end
81 |
82 | // 版权属于原作者
83 | // http://code4app.com (cn) http://code4app.net (en)
84 | // 发布代码于最专业的源码分享网站: Code4App.com
85 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASConstraint+Private.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraint+Private.h
3 | // Masonry
4 | //
5 | // Created by Nick Tymchenko on 29/04/14.
6 | // Copyright (c) 2014 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 |
11 | @protocol MASConstraintDelegate;
12 |
13 |
14 | @interface MASConstraint ()
15 |
16 | /**
17 | * Whether or not to check for an existing constraint instead of adding constraint
18 | */
19 | @property (nonatomic, assign) BOOL updateExisting;
20 |
21 | /**
22 | * Usually MASConstraintMaker but could be a parent MASConstraint
23 | */
24 | @property (nonatomic, weak) id delegate;
25 |
26 | /**
27 | * Based on a provided value type, is equal to calling:
28 | * NSNumber - setOffset:
29 | * NSValue with CGPoint - setPointOffset:
30 | * NSValue with CGSize - setSizeOffset:
31 | * NSValue with MASEdgeInsets - setInsets:
32 | */
33 | - (void)setLayoutConstantWithValue:(NSValue *)value;
34 |
35 | @end
36 |
37 |
38 | @interface MASConstraint (Abstract)
39 |
40 | /**
41 | * Sets the constraint relation to given NSLayoutRelation
42 | * returns a block which accepts one of the following:
43 | * MASViewAttribute, UIView, NSValue, NSArray
44 | * see readme for more details.
45 | */
46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
47 |
48 | /**
49 | * Override to set a custom chaining behaviour
50 | */
51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
52 |
53 | @end
54 |
55 |
56 | @protocol MASConstraintDelegate
57 |
58 | /**
59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example
60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
61 | */
62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
63 |
64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
65 |
66 | @end
67 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCDatePickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCDatePickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCDatePickerView.h"
10 | #import "UIView+CCUtil.h"
11 |
12 | @implementation CCDatePickerView
13 |
14 | - (void)awakeFromNib
15 | {
16 | [super awakeFromNib];
17 |
18 | self.backgroundColor = [UIColor clearColor];
19 | [self.calendar reloadData];
20 | }
21 |
22 | - (void)setSelectDate:(NSDate *)date
23 | {
24 | [self.calendar setCurrentDate:[NSDate date]];
25 | [self.calendar setCurrentDateSelected:date];
26 |
27 | [self.contentView setCurrentDate:date];
28 | [self.menuView setCurrentDate:date];
29 | [self.calendar reloadData];
30 | [self.contentView reloadData];
31 | [self.contentView reloadAppearance];
32 | [self.menuView reloadAppearance];
33 | }
34 |
35 | - (void)layoutSubviews
36 | {
37 | [super layoutSubviews];
38 |
39 | [self.contentView layoutIfNeeded];
40 | [self.menuView layoutIfNeeded];
41 |
42 | [self.calendar repositionViews];
43 | }
44 |
45 | #pragma mark - JTCalendarDataSource
46 |
47 | - (BOOL)calendarHaveEvent:(JTCalendar *)calendar date:(NSDate *)date
48 | {
49 | return NO;
50 | }
51 |
52 | - (void)calendarDidDateSelected:(JTCalendar *)calendar date:(NSDate *)date
53 | {
54 | if (self.delegate && [self.delegate respondsToSelector:@selector(datePickerView:didSelectDate:)]) {
55 | [self.delegate datePickerView:self didSelectDate:date];
56 | }
57 | }
58 |
59 | #pragma mark - Getter & Setter
60 | - (JTCalendar *)calendar
61 | {
62 | if (!_calendar) {
63 | _calendar = [[JTCalendar alloc] init];
64 | _calendar.calendarAppearance.calendar.firstWeekday = 2;
65 | _calendar.calendarAppearance.dayCircleRatio = 9. / 10.;
66 | _calendar.calendarAppearance.ratioContentMenu = 1.;
67 | [_calendar setMenuMonthsView:self.menuView];
68 | [_calendar setContentView:self.contentView];
69 | [_calendar setDataSource:self];
70 | }
71 | return _calendar;
72 | }
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/30.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 |
24 | - (void)applicationWillResignActive:(UIApplication *)application {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
27 | }
28 |
29 |
30 | - (void)applicationDidEnterBackground:(UIApplication *)application {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 |
36 | - (void)applicationWillEnterForeground:(UIApplication *)application {
37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 |
41 | - (void)applicationDidBecomeActive:(UIApplication *)application {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 |
46 | - (void)applicationWillTerminate:(UIApplication *)application {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/CCTimePickerDemo.xcodeproj/xcuserdata/ehome.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
24 |
36 |
37 |
38 |
40 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/CCTimePicker/CCYearPickerView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCYearPickerView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/UIView+CCUtil.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+CCUtil.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "UIView+CCUtil.h"
10 |
11 | @implementation UIView (CCUtil)
12 |
13 | + (instancetype)viewFromXib
14 | {
15 | Class viewClass = [self class];
16 | NSString *viewClassName = NSStringFromClass(viewClass);
17 | NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:viewClassName owner:nil options:nil];
18 |
19 | for (id nibItem in nibArray) {
20 | if ([nibItem isMemberOfClass:viewClass]) {
21 | return nibItem;
22 | }
23 | }
24 |
25 | return nil;
26 | }
27 |
28 | - (CGPoint)origin {
29 | return self.frame.origin;
30 | }
31 |
32 | - (void)setOrigin:(CGPoint)origin {
33 | CGRect frame = self.frame;
34 |
35 | frame.origin = origin;
36 |
37 | self.frame = frame;
38 | }
39 |
40 | - (CGFloat)originX {
41 | return self.frame.origin.x;
42 | }
43 |
44 | - (void)setOriginX:(CGFloat)originX {
45 | CGRect frame = self.frame;
46 |
47 | frame.origin.x = originX;
48 |
49 | self.frame = frame;
50 | }
51 |
52 | - (CGFloat)originY {
53 | return self.frame.origin.y;
54 | }
55 |
56 | - (void)setOriginY:(CGFloat)originY {
57 | CGRect frame = self.frame;
58 |
59 | frame.origin.y = originY;
60 |
61 | self.frame = frame;
62 | }
63 |
64 | - (CGSize)size {
65 | return self.frame.size;
66 | }
67 |
68 | - (void)setSize:(CGSize)size {
69 | CGRect frame = self.frame;
70 |
71 | frame.size = size;
72 |
73 | self.frame = frame;
74 | }
75 |
76 | - (CGFloat)sizeW {
77 | return self.frame.size.width;
78 | }
79 |
80 | - (void)setSizeW:(CGFloat)sizeW {
81 | CGRect frame = self.frame;
82 |
83 | frame.size.width = sizeW;
84 |
85 | self.frame = frame;
86 | }
87 |
88 | - (CGFloat)sizeH {
89 | return self.frame.size.height;
90 | }
91 |
92 | - (void)setSizeH:(CGFloat)sizeH {
93 | CGRect frame = self.frame;
94 |
95 | frame.size.height = sizeH;
96 |
97 | self.frame = frame;
98 | }
99 |
100 | - (CGFloat)centerX{
101 | return self.center.x;
102 | }
103 |
104 | - (void)setCenterX:(CGFloat)centerX{
105 | self.center = CGPointMake(centerX, self.centerY);
106 | }
107 |
108 | - (CGFloat)centerY{
109 | return self.center.y;
110 | }
111 |
112 | - (void)setCenterY:(CGFloat)centerY{
113 | self.center = CGPointMake(self.centerX, centerY);
114 | }
115 |
116 |
117 | @end
118 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarAppearance.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarAppearance.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @interface JTCalendarAppearance : NSObject
11 |
12 | typedef NS_ENUM(NSInteger, JTCalendarWeekDayFormat) {
13 | JTCalendarWeekDayFormatSingle,
14 | JTCalendarWeekDayFormatShort,
15 | JTCalendarWeekDayFormatFull
16 | };
17 |
18 | @property (assign, nonatomic) BOOL isWeekMode;
19 |
20 | // Month
21 | @property (strong, nonatomic) UIColor *menuMonthTextColor;
22 | @property (strong, nonatomic) UIFont *menuMonthTextFont;
23 |
24 | @property (assign, nonatomic) CGFloat ratioContentMenu;
25 |
26 | // Weekday
27 | @property (assign, nonatomic) JTCalendarWeekDayFormat weekDayFormat;
28 | @property (strong, nonatomic) UIColor *weekDayTextColor;
29 | @property (strong, nonatomic) UIFont *weekDayTextFont;
30 |
31 | // Day
32 | @property (strong, nonatomic) UIColor *dayCircleColorSelected;
33 | @property (strong, nonatomic) UIColor *dayCircleColorSelectedOtherMonth;
34 | @property (strong, nonatomic) UIColor *dayCircleColorToday;
35 | @property (strong, nonatomic) UIColor *dayCircleColorTodayOtherMonth;
36 |
37 | @property (strong, nonatomic) UIColor *dayDotColor;
38 | @property (strong, nonatomic) UIColor *dayDotColorSelected;
39 | @property (strong, nonatomic) UIColor *dayDotColorOtherMonth;
40 | @property (strong, nonatomic) UIColor *dayDotColorSelectedOtherMonth;
41 | @property (strong, nonatomic) UIColor *dayDotColorToday;
42 | @property (strong, nonatomic) UIColor *dayDotColorTodayOtherMonth;
43 |
44 | @property (strong, nonatomic) UIColor *dayTextColor;
45 | @property (strong, nonatomic) UIColor *dayTextColorSelected;
46 | @property (strong, nonatomic) UIColor *dayTextColorOtherMonth;
47 | @property (strong, nonatomic) UIColor *dayTextColorSelectedOtherMonth;
48 | @property (strong, nonatomic) UIColor *dayTextColorToday;
49 | @property (strong, nonatomic) UIColor *dayTextColorTodayOtherMonth;
50 |
51 | @property (strong, nonatomic) UIFont *dayTextFont;
52 |
53 | @property (assign, nonatomic) CGFloat dayCircleRatio;
54 | @property (assign, nonatomic) CGFloat dayDotRatio;
55 |
56 | - (NSCalendar *)calendar;
57 |
58 | - (void)setDayDotColorForAll:(UIColor *)dotColor;
59 | - (void)setDayTextColorForAll:(UIColor *)textColor;
60 |
61 | @end
62 |
63 | // 版权属于原作者
64 | // http://code4app.com (cn) http://code4app.net (en)
65 | // 发布代码于最专业的源码分享网站: Code4App.com
66 |
67 | // 版权属于原作者
68 | // http://code4app.com (cn) http://code4app.net (en)
69 | // 发布代码于最专业的源码分享网站: Code4App.com
70 |
71 | // 版权属于原作者
72 | // http://code4app.com (cn) http://code4app.net (en)
73 | // 发布代码于最专业的源码分享网站: Code4App.com
74 |
--------------------------------------------------------------------------------
/CCTimePicker/CCYearPickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCYearPickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCYearPickerView.h"
10 |
11 | @interface CCYearPickerView()
12 |
13 | @property (nonatomic, strong) NSMutableArray *yearArray;
14 |
15 | @end
16 |
17 | @implementation CCYearPickerView
18 |
19 | - (instancetype)init
20 | {
21 | self = [super init];
22 | if (self) {
23 | [self setup];
24 | }
25 | return self;
26 | }
27 |
28 | - (instancetype)initWithFrame:(CGRect)frame
29 | {
30 | self = [super initWithFrame:frame];
31 | if (self) {
32 | [self setup];
33 | }
34 | return self;
35 | }
36 |
37 | - (void)awakeFromNib
38 | {
39 | [super awakeFromNib];
40 |
41 | [self setup];
42 | }
43 |
44 | - (void)setup
45 | {
46 | self.backgroundColor = [UIColor clearColor];
47 | for (NSInteger i = 1970; i < 2050; i ++) {
48 | [self.yearArray addObject:@(i).stringValue];
49 | }
50 |
51 | self.yearPickerView.delegate = self;
52 | self.yearPickerView.dataSource = self;
53 | [self.yearPickerView reloadAllComponents];
54 |
55 | [self.yearPickerView selectRow:(2017 - 1970) inComponent:0 animated:NO];
56 | }
57 |
58 | #pragma mark - UIPickerViewDelegate
59 |
60 | - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
61 | {
62 | return 36;
63 | }
64 |
65 | - (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
66 | {
67 | return [self.yearArray objectAtIndex:row];
68 | }
69 |
70 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
71 | {
72 | NSString *selectYear = [self.yearArray objectAtIndex:row];
73 | if (self.delegate && [self.delegate respondsToSelector:@selector(yearPikcerView:didSelectYear:)]) {
74 | [self.delegate yearPikcerView:self didSelectYear:selectYear];
75 | }
76 | }
77 |
78 |
79 | #pragma mark - UIPickerViewDataSource
80 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
81 | {
82 | return 1;
83 | }
84 |
85 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
86 | {
87 | return self.yearArray.count;
88 | }
89 |
90 | #pragma mark - Getter && Setter
91 | - (NSMutableArray *)yearArray
92 | {
93 | if (!_yearArray) {
94 | _yearArray = [NSMutableArray arrayWithCapacity:80];
95 | }
96 | return _yearArray;
97 | }
98 |
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCYearPickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCYearPickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCYearPickerView.h"
10 |
11 | @interface CCYearPickerView()
12 |
13 | @property (nonatomic, strong) NSMutableArray *yearArray;
14 |
15 | @end
16 |
17 | @implementation CCYearPickerView
18 |
19 | - (instancetype)init
20 | {
21 | self = [super init];
22 | if (self) {
23 | [self setup];
24 | }
25 | return self;
26 | }
27 |
28 | - (instancetype)initWithFrame:(CGRect)frame
29 | {
30 | self = [super initWithFrame:frame];
31 | if (self) {
32 | [self setup];
33 | }
34 | return self;
35 | }
36 |
37 | - (void)awakeFromNib
38 | {
39 | [super awakeFromNib];
40 |
41 | [self setup];
42 | }
43 |
44 | - (void)setup
45 | {
46 | self.backgroundColor = [UIColor clearColor];
47 | for (NSInteger i = 1970; i < 2050; i ++) {
48 | [self.yearArray addObject:@(i).stringValue];
49 | }
50 |
51 | self.yearPickerView.delegate = self;
52 | self.yearPickerView.dataSource = self;
53 | [self.yearPickerView reloadAllComponents];
54 |
55 | [self.yearPickerView selectRow:(2017 - 1970) inComponent:0 animated:NO];
56 | }
57 |
58 | #pragma mark - UIPickerViewDelegate
59 |
60 | - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
61 | {
62 | return 36;
63 | }
64 |
65 | - (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
66 | {
67 | return [self.yearArray objectAtIndex:row];
68 | }
69 |
70 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
71 | {
72 | NSString *selectYear = [self.yearArray objectAtIndex:row];
73 | if (self.delegate && [self.delegate respondsToSelector:@selector(yearPikcerView:didSelectYear:)]) {
74 | [self.delegate yearPikcerView:self didSelectYear:selectYear];
75 | }
76 | }
77 |
78 |
79 | #pragma mark - UIPickerViewDataSource
80 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
81 | {
82 | return 1;
83 | }
84 |
85 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
86 | {
87 | return self.yearArray.count;
88 | }
89 |
90 | #pragma mark - Getter && Setter
91 | - (NSMutableArray *)yearArray
92 | {
93 | if (!_yearArray) {
94 | _yearArray = [NSMutableArray arrayWithCapacity:80];
95 | }
96 | return _yearArray;
97 | }
98 |
99 |
100 | @end
101 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCHourPickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCHourPickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCHourPickerView.h"
10 | #import "CCHourCircleSlider.h"
11 | #import "NSDate+CCUtil.h"
12 |
13 | @interface CCHourPickerView()
14 |
15 | @property (nonatomic, strong) CCHourCircleSlider *hourSlider;
16 |
17 | @end
18 |
19 | @implementation CCHourPickerView
20 |
21 | - (instancetype)init
22 | {
23 | self = [super init];
24 | if (self) {
25 | self.backgroundColor = [UIColor clearColor];
26 | [self addSubview:self.hourSlider];
27 | }
28 | return self;
29 | }
30 |
31 | - (instancetype)initWithFrame:(CGRect)frame
32 | {
33 | self = [super initWithFrame:frame];
34 | if (self) {
35 | self.backgroundColor = [UIColor clearColor];
36 | [self addSubview:self.hourSlider];
37 | }
38 | return self;
39 | }
40 |
41 | - (void)layoutSubviews
42 | {
43 | [super layoutSubviews];
44 |
45 | if (self.bounds.size.width > self.bounds.size.height) {
46 | _hourSlider.frame = CGRectMake(0, 0, self.bounds.size.height - 20, self.bounds.size.height - 20);
47 | _hourSlider.center = self.center;
48 | }else
49 | {
50 | _hourSlider.frame = CGRectMake(0, 0, self.bounds.size.width - 20, self.bounds.size.width - 20);
51 | _hourSlider.center = self.center;
52 | }
53 |
54 | }
55 |
56 | #pragma mark - Public
57 | - (void)setHourWithDate:(NSDate *)date{
58 | NSString *hour = [date stringForDateWithFormat:@"HH"];
59 | NSInteger hourNumber;
60 |
61 | hourNumber = hour.integerValue;
62 |
63 | self.hour = hourNumber;
64 | [self.hourSlider setHour:hourNumber];
65 | }
66 |
67 | #pragma mark - Event
68 | - (void)hourSliderEndSelect:(CCHourCircleSlider *)sender
69 | {
70 | NSString *hourString = [NSString stringWithFormat:@"%02ld",(long)sender.hour];
71 | if (self.delegate && [self.delegate respondsToSelector:@selector(hourPickerView:hourSelectEnd:)]) {
72 | [self.delegate hourPickerView:self hourSelectEnd:hourString];
73 | }
74 | }
75 |
76 | - (void)hourSliderDidSelect:(CCHourCircleSlider *)sender
77 | {
78 | NSString *hourString = [NSString stringWithFormat:@"%02ld",(long)sender.hour];
79 | if (self.delegate && [self.delegate respondsToSelector:@selector(hourPickerView:didSelectHour:)]) {
80 | [self.delegate hourPickerView:self didSelectHour:hourString];
81 | }
82 | }
83 |
84 |
85 | #pragma mark - Getter && Setter
86 | - (CCHourCircleSlider *)hourSlider
87 | {
88 | if (!_hourSlider) {
89 | _hourSlider = [[CCHourCircleSlider alloc] init];
90 | [_hourSlider addTarget:self action:@selector(hourSliderEndSelect:) forControlEvents:UIControlEventEditingDidEnd];
91 | [_hourSlider addTarget:self action:@selector(hourSliderDidSelect:) forControlEvents:UIControlEventValueChanged];
92 | }
93 | return _hourSlider;
94 | }
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarAppearance.h:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarAppearance.h
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import
9 |
10 | @class JTCalendar;
11 |
12 | @interface JTCalendarAppearance : NSObject
13 |
14 | typedef NS_ENUM(NSInteger, JTCalendarWeekDayFormat) {
15 | JTCalendarWeekDayFormatSingle,
16 | JTCalendarWeekDayFormatShort,
17 | JTCalendarWeekDayFormatFull
18 | };
19 |
20 | typedef NSString *(^JTCalendarMonthBlock)(NSDate *date, JTCalendar *jt_calendar);
21 |
22 | @property (assign, nonatomic) BOOL isWeekMode;
23 | @property (assign, nonatomic) BOOL useCacheSystem;
24 | @property (assign, nonatomic) BOOL focusSelectedDayChangeMode;
25 | @property (assign, nonatomic) BOOL readFromRightToLeft; // For language read from right to left
26 |
27 | // Month
28 | @property (strong, nonatomic) UIColor *menuMonthTextColor;
29 | @property (strong, nonatomic) UIFont *menuMonthTextFont;
30 |
31 | @property (assign, nonatomic) CGFloat ratioContentMenu;
32 | @property (assign, nonatomic) BOOL autoChangeMonth;
33 | @property (nonatomic, copy) JTCalendarMonthBlock monthBlock;
34 |
35 | // Weekday
36 | @property (assign, nonatomic) JTCalendarWeekDayFormat weekDayFormat;
37 | @property (strong, nonatomic) UIColor *weekDayTextColor;
38 | @property (strong, nonatomic) UIFont *weekDayTextFont;
39 |
40 | // Day
41 | @property (strong, nonatomic) UIColor *dayCircleColorSelected;
42 | @property (strong, nonatomic) UIColor *dayCircleColorSelectedOtherMonth;
43 | @property (strong, nonatomic) UIColor *dayCircleColorToday;
44 | @property (strong, nonatomic) UIColor *dayCircleColorTodayOtherMonth;
45 |
46 | @property (strong, nonatomic) UIColor *dayDotColor;
47 | @property (strong, nonatomic) UIColor *dayDotColorSelected;
48 | @property (strong, nonatomic) UIColor *dayDotColorOtherMonth;
49 | @property (strong, nonatomic) UIColor *dayDotColorSelectedOtherMonth;
50 | @property (strong, nonatomic) UIColor *dayDotColorToday;
51 | @property (strong, nonatomic) UIColor *dayDotColorTodayOtherMonth;
52 |
53 | @property (strong, nonatomic) UIColor *dayTextColor;
54 | @property (strong, nonatomic) UIColor *dayTextColorSelected;
55 | @property (strong, nonatomic) UIColor *dayTextColorOtherMonth;
56 | @property (strong, nonatomic) UIColor *dayTextColorSelectedOtherMonth;
57 | @property (strong, nonatomic) UIColor *dayTextColorToday;
58 | @property (strong, nonatomic) UIColor *dayTextColorTodayOtherMonth;
59 |
60 | @property (strong, nonatomic) UIFont *dayTextFont;
61 |
62 | @property (strong, nonatomic) NSString *dayFormat;
63 |
64 | // Day Background and Border
65 | @property (strong, nonatomic) UIColor *dayBackgroundColor;
66 | @property (assign, nonatomic) CGFloat dayBorderWidth;
67 | @property (assign, nonatomic) UIColor *dayBorderColor;
68 |
69 | @property (assign, nonatomic) CGFloat dayCircleRatio;
70 | @property (assign, nonatomic) CGFloat dayDotRatio;
71 |
72 | - (NSCalendar *)calendar;
73 |
74 | - (void)setDayDotColorForAll:(UIColor *)dotColor;
75 | - (void)setDayTextColorForAll:(UIColor *)textColor;
76 |
77 | @end
78 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/NSArray+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSArray+MASAdditions.h
3 | //
4 | //
5 | // Created by Daniel Hammond on 11/26/13.
6 | //
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | typedef NS_ENUM(NSUInteger, MASAxisType) {
14 | MASAxisTypeHorizontal,
15 | MASAxisTypeVertical
16 | };
17 |
18 | @interface NSArray (MASAdditions)
19 |
20 | /**
21 | * Creates a MASConstraintMaker with each view in the callee.
22 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
23 | *
24 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
25 | *
26 | * @return Array of created MASConstraints
27 | */
28 | - (NSArray *)mas_makeConstraints:(void (^)(MASConstraintMaker *make))block;
29 |
30 | /**
31 | * Creates a MASConstraintMaker with each view in the callee.
32 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
33 | * If an existing constraint exists then it will be updated instead.
34 | *
35 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
36 | *
37 | * @return Array of created/updated MASConstraints
38 | */
39 | - (NSArray *)mas_updateConstraints:(void (^)(MASConstraintMaker *make))block;
40 |
41 | /**
42 | * Creates a MASConstraintMaker with each view in the callee.
43 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
44 | * All constraints previously installed for the views will be removed.
45 | *
46 | * @param block scope within which you can build up the constraints which you wish to apply to each view.
47 | *
48 | * @return Array of created/updated MASConstraints
49 | */
50 | - (NSArray *)mas_remakeConstraints:(void (^)(MASConstraintMaker *make))block;
51 |
52 | /**
53 | * distribute with fixed spacing
54 | *
55 | * @param axisType which axis to distribute items along
56 | * @param fixedSpacing the spacing between each item
57 | * @param leadSpacing the spacing before the first item and the container
58 | * @param tailSpacing the spacing after the last item and the container
59 | */
60 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
61 |
62 | /**
63 | * distribute with fixed item size
64 | *
65 | * @param axisType which axis to distribute items along
66 | * @param fixedItemLength the fixed length of each item
67 | * @param leadSpacing the spacing before the first item and the container
68 | * @param tailSpacing the spacing after the last item and the container
69 | */
70 | - (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCMinitePickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCMinitePickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCMinitePickerView.h"
10 | #import "CCMiniteCircleSlider.h"
11 | #import "NSDate+CCUtil.h"
12 |
13 | @interface CCMinitePickerView()
14 |
15 | @property (nonatomic, strong) CCMiniteCircleSlider *miniteCircleSlider;
16 |
17 | @end
18 |
19 | @implementation CCMinitePickerView
20 |
21 | - (instancetype)init
22 | {
23 | self = [super init];
24 | if (self) {
25 | self.backgroundColor = [UIColor clearColor];
26 | [self addSubview:self.miniteCircleSlider];
27 | }
28 | return self;
29 | }
30 |
31 | - (instancetype)initWithFrame:(CGRect)frame
32 | {
33 | self = [super initWithFrame:frame];
34 | if (self) {
35 | self.backgroundColor = [UIColor clearColor];
36 | [self addSubview:self.miniteCircleSlider];
37 | }
38 | return self;
39 | }
40 |
41 | - (void)layoutSubviews
42 | {
43 | [super layoutSubviews];
44 |
45 | if (self.bounds.size.width > self.bounds.size.height) {
46 | self.miniteCircleSlider.frame = CGRectMake(0, 0, self.bounds.size.height - 20, self.bounds.size.height - 20);
47 | self.miniteCircleSlider.center = self.center;
48 | }else
49 | {
50 | self.miniteCircleSlider.frame = CGRectMake(0, 0, self.bounds.size.width - 20, self.bounds.size.width - 20);
51 | self.miniteCircleSlider.center = self.center;
52 | }
53 | }
54 |
55 | #pragma mark - Public
56 | - (void)setMiniteWithDate:(NSDate *)date{
57 | NSString *minite = [date stringForDateWithFormat:@"mm"];
58 |
59 | self.minite = minite.integerValue;
60 |
61 | [self.miniteCircleSlider setMinite:self.minite];
62 | }
63 |
64 | #pragma mark - Event
65 |
66 | - (void)miniteSliderEndSelect:(CCMiniteCircleSlider *)sender
67 | {
68 | NSString *miniteString = [NSString stringWithFormat:@"%02ld",(long)sender.minite];
69 | if (self.delegate && [self.delegate respondsToSelector:@selector(minitePickerView:miniteSelectEnd:)]) {
70 | [self.delegate minitePickerView:self miniteSelectEnd:miniteString];
71 | }
72 | }
73 |
74 | - (void)miniteSliderDidSelect:(CCMiniteCircleSlider *)sender
75 | {
76 | NSString *miniteString = [NSString stringWithFormat:@"%02ld",(long)sender.minite];
77 | if (self.delegate && [self.delegate respondsToSelector:@selector(minitePickerView:didSelectMinite:)]) {
78 | [self.delegate minitePickerView:self didSelectMinite:miniteString];
79 | }
80 | }
81 |
82 |
83 | #pragma mark - Getter && Setter
84 | - (CCMiniteCircleSlider *)miniteCircleSlider
85 | {
86 | if (!_miniteCircleSlider) {
87 | _miniteCircleSlider = [[CCMiniteCircleSlider alloc] init];
88 | [_miniteCircleSlider addTarget:self action:@selector(miniteSliderEndSelect:) forControlEvents:UIControlEventEditingDidEnd];
89 | [_miniteCircleSlider addTarget:self action:@selector(miniteSliderDidSelect:) forControlEvents:UIControlEventValueChanged];
90 | }
91 | return _miniteCircleSlider;
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/CCTimePicker/CCMinitePickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCMinitePickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCMinitePickerView.h"
10 | #import "CCMiniteCircleSlider.h"
11 | #import "NSDate+CCUtil.h"
12 |
13 | @interface CCMinitePickerView()
14 |
15 | @property (nonatomic, strong) CCMiniteCircleSlider *miniteCircleSlider;
16 |
17 | @end
18 |
19 | @implementation CCMinitePickerView
20 |
21 | - (instancetype)init
22 | {
23 | self = [super init];
24 | if (self) {
25 | self.backgroundColor = [UIColor clearColor];
26 | [self addSubview:self.miniteCircleSlider];
27 | }
28 | return self;
29 | }
30 |
31 | - (instancetype)initWithFrame:(CGRect)frame
32 | {
33 | self = [super initWithFrame:frame];
34 | if (self) {
35 | self.backgroundColor = [UIColor clearColor];
36 | [self addSubview:self.miniteCircleSlider];
37 | }
38 | return self;
39 | }
40 |
41 | - (void)layoutSubviews
42 | {
43 | [super layoutSubviews];
44 |
45 | if (self.bounds.size.width != self.bounds.size.height) {
46 | if (self.bounds.size.width > self.bounds.size.height) {
47 | self.miniteCircleSlider.frame = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.height);
48 | self.miniteCircleSlider.center = self.center;
49 | }else
50 | {
51 | self.miniteCircleSlider.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.width);
52 | self.miniteCircleSlider.center = self.center;
53 | }
54 | }else
55 | {
56 | self.miniteCircleSlider.frame = self.bounds;
57 | }
58 | }
59 |
60 | #pragma mark - Public
61 | - (void)setMiniteWithDate:(NSDate *)date{
62 | NSString *minite = [date dateToString:@"mm"];
63 |
64 | self.minite = minite.integerValue;
65 |
66 | [self.miniteCircleSlider setMinite:self.minite];
67 | }
68 |
69 | #pragma mark - Event
70 |
71 | - (void)miniteSliderEndSelect:(CCMiniteCircleSlider *)sender
72 | {
73 | NSString *miniteString = @(sender.minite).stringValue;
74 | if (self.delegate && [self.delegate respondsToSelector:@selector(minitePickerView:miniteSelectEnd:)]) {
75 | [self.delegate minitePickerView:self miniteSelectEnd:miniteString];
76 | }
77 | }
78 |
79 | - (void)miniteSliderDidSelect:(CCMiniteCircleSlider *)sender
80 | {
81 | NSString *miniteString = @(sender.minite).stringValue;
82 | if (self.delegate && [self.delegate respondsToSelector:@selector(minitePickerView:didSelectMinite:)]) {
83 | [self.delegate minitePickerView:self didSelectMinite:miniteString];
84 | }
85 | }
86 |
87 |
88 | #pragma mark - Getter && Setter
89 | - (CCMiniteCircleSlider *)miniteCircleSlider
90 | {
91 | if (!_miniteCircleSlider) {
92 | _miniteCircleSlider = [[CCMiniteCircleSlider alloc] init];
93 | [_miniteCircleSlider addTarget:self action:@selector(miniteSliderEndSelect:) forControlEvents:UIControlEventEditingDidEnd];
94 | [_miniteCircleSlider addTarget:self action:@selector(miniteSliderDidSelect:) forControlEvents:UIControlEventValueChanged];
95 | }
96 | return _miniteCircleSlider;
97 | }
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarWeekView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarWeekView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarWeekView.h"
9 |
10 | #import "JTCalendarDayView.h"
11 |
12 | @interface JTCalendarWeekView (){
13 | NSArray *daysViews;
14 | };
15 |
16 | @end
17 |
18 | @implementation JTCalendarWeekView
19 |
20 | - (instancetype)initWithFrame:(CGRect)frame
21 | {
22 | self = [super initWithFrame:frame];
23 | if(!self){
24 | return nil;
25 | }
26 |
27 | [self commonInit];
28 |
29 | return self;
30 | }
31 |
32 | - (id)initWithCoder:(NSCoder *)aDecoder
33 | {
34 | self = [super initWithCoder:aDecoder];
35 | if(!self){
36 | return nil;
37 | }
38 |
39 | [self commonInit];
40 |
41 | return self;
42 | }
43 |
44 | - (void)commonInit
45 | {
46 | NSMutableArray *views = [NSMutableArray new];
47 |
48 | for(int i = 0; i < 7; ++i){
49 | UIView *view = [JTCalendarDayView new];
50 |
51 | [views addObject:view];
52 | [self addSubview:view];
53 | }
54 |
55 | daysViews = views;
56 | }
57 |
58 | - (void)layoutSubviews
59 | {
60 | CGFloat x = 0;
61 | CGFloat width = self.frame.size.width / 7.;
62 | CGFloat height = self.frame.size.height;
63 |
64 | for(UIView *view in self.subviews){
65 | view.frame = CGRectMake(x, 0, width, height);
66 | x = CGRectGetMaxX(view.frame);
67 | }
68 |
69 | [super layoutSubviews];
70 | }
71 |
72 | - (void)setBeginningOfWeek:(NSDate *)date
73 | {
74 | NSDate *currentDate = date;
75 |
76 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
77 |
78 | for(JTCalendarDayView *view in daysViews){
79 | if(!self.calendarManager.calendarAppearance.isWeekMode){
80 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth fromDate:currentDate];
81 | NSInteger monthIndex = comps.month;
82 |
83 | [view setIsOtherMonth:monthIndex != self.currentMonthIndex];
84 | }
85 | else{
86 | [view setIsOtherMonth:NO];
87 | }
88 |
89 | [view setDate:currentDate];
90 |
91 | NSDateComponents *dayComponent = [NSDateComponents new];
92 | dayComponent.day = 1;
93 |
94 | currentDate = [calendar dateByAddingComponents:dayComponent toDate:currentDate options:0];
95 | }
96 | }
97 |
98 | #pragma mark - JTCalendarManager
99 |
100 | - (void)setCalendarManager:(JTCalendar *)calendarManager
101 | {
102 | self->_calendarManager = calendarManager;
103 | for(JTCalendarDayView *view in daysViews){
104 | [view setCalendarManager:calendarManager];
105 | }
106 | }
107 |
108 | - (void)reloadData
109 | {
110 | for(JTCalendarDayView *view in daysViews){
111 | [view reloadData];
112 | }
113 | }
114 |
115 | - (void)reloadAppearance
116 | {
117 | for(JTCalendarDayView *view in daysViews){
118 | [view reloadAppearance];
119 | }
120 | }
121 |
122 | @end
123 |
124 | // 版权属于原作者
125 | // http://code4app.com (cn) http://code4app.net (en)
126 | // 发布代码于最专业的源码分享网站: Code4App.com
127 |
--------------------------------------------------------------------------------
/CCTimePicker/CCHourPickerView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CCHourPickerView.m
3 | // CCTimePickerDemo
4 | //
5 | // Created by eHome on 17/3/31.
6 | // Copyright © 2017年 Bref. All rights reserved.
7 | //
8 |
9 | #import "CCHourPickerView.h"
10 | #import "CCHourCircleSlider.h"
11 | #import "NSDate+CCUtil.h"
12 |
13 | @interface CCHourPickerView()
14 |
15 | @property (nonatomic, strong) CCHourCircleSlider *hourSlider;
16 |
17 | @end
18 |
19 | @implementation CCHourPickerView
20 |
21 | - (instancetype)init
22 | {
23 | self = [super init];
24 | if (self) {
25 | self.backgroundColor = [UIColor clearColor];
26 | [self addSubview:self.hourSlider];
27 | }
28 | return self;
29 | }
30 |
31 | - (instancetype)initWithFrame:(CGRect)frame
32 | {
33 | self = [super initWithFrame:frame];
34 | if (self) {
35 | self.backgroundColor = [UIColor clearColor];
36 | [self addSubview:self.hourSlider];
37 | }
38 | return self;
39 | }
40 |
41 | - (void)layoutSubviews
42 | {
43 | [super layoutSubviews];
44 |
45 | if (self.bounds.size.width != self.bounds.size.height) {
46 | if (self.bounds.size.width > self.bounds.size.height) {
47 | _hourSlider.frame = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.height);
48 | _hourSlider.center = self.center;
49 | }else
50 | {
51 | _hourSlider.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.width);
52 | _hourSlider.center = self.center;
53 | }
54 | }else
55 | {
56 | _hourSlider.frame = self.bounds;
57 | }
58 | }
59 |
60 | #pragma mark - Public
61 | - (void)setHourWithDate:(NSDate *)date{
62 | NSString *hour = [date dateToString:@"HH"];
63 | NSInteger hourNumber;
64 | if (hour.integerValue > 12) {
65 | self.state = CCHourPickerViewStatePM;
66 | hourNumber = hour.integerValue - 12;
67 | }else
68 | {
69 | hourNumber = hour.integerValue;
70 | }
71 |
72 | self.hour = hourNumber;
73 | [self.hourSlider setHour:hourNumber];
74 | }
75 |
76 | #pragma mark - Event
77 | - (void)hourSliderEndSelect:(CCHourCircleSlider *)sender
78 | {
79 | NSString *hourString = [NSString stringWithFormat:@"%02ld",(long)sender.hour];
80 | if (self.delegate && [self.delegate respondsToSelector:@selector(hourPickerView:hourSelectEnd:)]) {
81 | [self.delegate hourPickerView:self hourSelectEnd:hourString];
82 | }
83 | }
84 |
85 | - (void)hourSliderDidSelect:(CCHourCircleSlider *)sender
86 | {
87 | NSString *hourString = [NSString stringWithFormat:@"%02ld",(long)sender.hour];
88 | if (self.delegate && [self.delegate respondsToSelector:@selector(hourPickerView:didSelectHour:)]) {
89 | [self.delegate hourPickerView:self didSelectHour:hourString];
90 | }
91 | }
92 |
93 |
94 | #pragma mark - Getter && Setter
95 | - (CCHourCircleSlider *)hourSlider
96 | {
97 | if (!_hourSlider) {
98 | _hourSlider = [[CCHourCircleSlider alloc] init];
99 | [_hourSlider addTarget:self action:@selector(hourSliderEndSelect:) forControlEvents:UIControlEventEditingDidEnd];
100 | [_hourSlider addTarget:self action:@selector(hourSliderDidSelect:) forControlEvents:UIControlEventValueChanged];
101 | }
102 | return _hourSlider;
103 | }
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarAppearance.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarAppearance.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarAppearance.h"
9 |
10 | @implementation JTCalendarAppearance
11 |
12 | - (instancetype)init
13 | {
14 | self = [super init];
15 | if(!self){
16 | return nil;
17 | }
18 |
19 | [self setDefaultValues];
20 |
21 | return self;
22 | }
23 |
24 | - (void)setDefaultValues
25 | {
26 | self.isWeekMode = NO;
27 |
28 | self.weekDayFormat = JTCalendarWeekDayFormatShort;
29 |
30 | self.ratioContentMenu = 2.;
31 | self.dayCircleRatio = 1.;
32 | self.dayDotRatio = 1. / 9.;
33 |
34 | self.menuMonthTextFont = [UIFont systemFontOfSize:17.];
35 | self.weekDayTextFont = [UIFont systemFontOfSize:11];
36 | self.dayTextFont = [UIFont systemFontOfSize:[UIFont systemFontSize]];
37 |
38 | self.menuMonthTextColor = [UIColor blackColor];
39 | self.weekDayTextColor = [UIColor colorWithRed:152./256. green:147./256. blue:157./256. alpha:1.];
40 |
41 | [self setDayDotColorForAll:[UIColor colorWithRed:43./256. green:88./256. blue:134./256. alpha:1.]];
42 | [self setDayTextColorForAll:[UIColor blackColor]];
43 |
44 | self.dayTextColorOtherMonth = [UIColor colorWithRed:152./256. green:147./256. blue:157./256. alpha:1.];
45 |
46 | self.dayCircleColorSelected = [UIColor redColor];
47 | self.dayTextColorSelected = [UIColor whiteColor];
48 | self.dayDotColorSelected = [UIColor whiteColor];
49 |
50 | self.dayCircleColorSelectedOtherMonth = self.dayCircleColorSelected;
51 | self.dayTextColorSelectedOtherMonth = self.dayTextColorSelected;
52 | self.dayDotColorSelectedOtherMonth = self.dayDotColorSelected;
53 |
54 | self.dayCircleColorToday = [UIColor colorWithRed:0x33/256. green:0xB3/256. blue:0xEC/256. alpha:.5];
55 | self.dayTextColorToday = [UIColor whiteColor];
56 | self.dayDotColorToday = [UIColor whiteColor];
57 |
58 | self.dayCircleColorTodayOtherMonth = self.dayCircleColorToday;
59 | self.dayTextColorTodayOtherMonth = self.dayTextColorToday;
60 | self.dayDotColorTodayOtherMonth = self.dayDotColorToday;
61 | }
62 |
63 | - (NSCalendar *)calendar
64 | {
65 | static NSCalendar *calendar;
66 | static dispatch_once_t once;
67 |
68 | dispatch_once(&once, ^{
69 | calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
70 | calendar.timeZone = [NSTimeZone localTimeZone];
71 | });
72 |
73 | return calendar;
74 | }
75 |
76 | - (void)setDayDotColorForAll:(UIColor *)dotColor
77 | {
78 | self.dayDotColor = dotColor;
79 | self.dayDotColorSelected = dotColor;
80 |
81 | self.dayDotColorOtherMonth = dotColor;
82 | self.dayDotColorSelectedOtherMonth = dotColor;
83 |
84 | self.dayDotColorToday = dotColor;
85 | self.dayDotColorTodayOtherMonth = dotColor;
86 | }
87 |
88 | - (void)setDayTextColorForAll:(UIColor *)textColor
89 | {
90 | self.dayTextColor = textColor;
91 | self.dayTextColorSelected = textColor;
92 |
93 | self.dayTextColorOtherMonth = textColor;
94 | self.dayTextColorSelectedOtherMonth = textColor;
95 |
96 | self.dayTextColorToday = textColor;
97 | self.dayTextColorTodayOtherMonth = textColor;
98 | }
99 |
100 | @end
101 |
102 | // 版权属于原作者
103 | // http://code4app.com (cn) http://code4app.net (en)
104 | // 发布代码于最专业的源码分享网站: Code4App.com
105 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarWeekView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarWeekView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarWeekView.h"
9 |
10 | #import "JTCalendarDayView.h"
11 |
12 | @interface JTCalendarWeekView (){
13 | NSArray *daysViews;
14 | };
15 |
16 | @end
17 |
18 | @implementation JTCalendarWeekView
19 |
20 | - (instancetype)initWithFrame:(CGRect)frame
21 | {
22 | self = [super initWithFrame:frame];
23 | if(!self){
24 | return nil;
25 | }
26 |
27 | [self commonInit];
28 |
29 | return self;
30 | }
31 |
32 | - (id)initWithCoder:(NSCoder *)aDecoder
33 | {
34 | self = [super initWithCoder:aDecoder];
35 | if(!self){
36 | return nil;
37 | }
38 |
39 | [self commonInit];
40 |
41 | return self;
42 | }
43 |
44 | - (void)commonInit
45 | {
46 | NSMutableArray *views = [NSMutableArray new];
47 |
48 | for(int i = 0; i < 7; ++i){
49 | UIView *view = [JTCalendarDayView new];
50 |
51 | [views addObject:view];
52 | [self addSubview:view];
53 | }
54 |
55 | daysViews = views;
56 | }
57 |
58 | - (void)layoutSubviews
59 | {
60 | CGFloat x = 0;
61 | CGFloat width = self.frame.size.width / 7.;
62 | CGFloat height = self.frame.size.height;
63 |
64 | if(self.calendarManager.calendarAppearance.readFromRightToLeft){
65 | for(UIView *view in [[self.subviews reverseObjectEnumerator] allObjects]){
66 | view.frame = CGRectMake(x, 0, width, height);
67 | x = CGRectGetMaxX(view.frame);
68 | }
69 | }
70 | else{
71 | for(UIView *view in self.subviews){
72 | view.frame = CGRectMake(x, 0, width, height);
73 | x = CGRectGetMaxX(view.frame);
74 | }
75 | }
76 |
77 | [super layoutSubviews];
78 | }
79 |
80 | - (void)setBeginningOfWeek:(NSDate *)date
81 | {
82 | NSDate *currentDate = date;
83 |
84 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
85 |
86 | for(JTCalendarDayView *view in daysViews){
87 | if(!self.calendarManager.calendarAppearance.isWeekMode){
88 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth fromDate:currentDate];
89 | NSInteger monthIndex = comps.month;
90 |
91 | [view setIsOtherMonth:monthIndex != self.currentMonthIndex];
92 | }
93 | else{
94 | [view setIsOtherMonth:NO];
95 | }
96 |
97 | [view setDate:currentDate];
98 |
99 | NSDateComponents *dayComponent = [NSDateComponents new];
100 | dayComponent.day = 1;
101 |
102 | currentDate = [calendar dateByAddingComponents:dayComponent toDate:currentDate options:0];
103 | }
104 | }
105 |
106 | #pragma mark - JTCalendarManager
107 |
108 | - (void)setCalendarManager:(JTCalendar *)calendarManager
109 | {
110 | self->_calendarManager = calendarManager;
111 | for(JTCalendarDayView *view in daysViews){
112 | [view setCalendarManager:calendarManager];
113 | }
114 | }
115 |
116 | - (void)reloadData
117 | {
118 | for(JTCalendarDayView *view in daysViews){
119 | [view reloadData];
120 | }
121 | }
122 |
123 | - (void)reloadAppearance
124 | {
125 | for(JTCalendarDayView *view in daysViews){
126 | [view reloadAppearance];
127 | }
128 | }
129 |
130 | @end
131 |
--------------------------------------------------------------------------------
/CCTimePicker/CCDatePickerView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/CCDatePickerView.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMonthWeekDaysView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthWeekDaysView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMonthWeekDaysView.h"
9 |
10 | @implementation JTCalendarMonthWeekDaysView
11 |
12 | static NSArray *cacheDaysOfWeeks;
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame
15 | {
16 | self = [super initWithFrame:frame];
17 | if(!self){
18 | return nil;
19 | }
20 |
21 | [self commonInit];
22 |
23 | return self;
24 | }
25 |
26 | - (id)initWithCoder:(NSCoder *)aDecoder
27 | {
28 | self = [super initWithCoder:aDecoder];
29 | if(!self){
30 | return nil;
31 | }
32 |
33 | [self commonInit];
34 |
35 | return self;
36 | }
37 |
38 | - (void)commonInit
39 | {
40 | for(NSString *day in [self daysOfWeek]){
41 | UILabel *view = [UILabel new];
42 |
43 | view.font = self.calendarManager.calendarAppearance.weekDayTextFont;
44 | view.textColor = self.calendarManager.calendarAppearance.weekDayTextColor;
45 |
46 | view.textAlignment = NSTextAlignmentCenter;
47 | view.text = day;
48 |
49 | [self addSubview:view];
50 | }
51 | }
52 |
53 | - (NSArray *)daysOfWeek
54 | {
55 | if(cacheDaysOfWeeks){
56 | return cacheDaysOfWeeks;
57 | }
58 |
59 | NSDateFormatter *dateFormatter = [NSDateFormatter new];
60 | NSMutableArray *days = nil;
61 |
62 | switch(self.calendarManager.calendarAppearance.weekDayFormat) {
63 | case JTCalendarWeekDayFormatSingle:
64 | days = [[dateFormatter veryShortStandaloneWeekdaySymbols] mutableCopy];
65 | break;
66 | case JTCalendarWeekDayFormatShort:
67 | days = [[dateFormatter shortStandaloneWeekdaySymbols] mutableCopy];
68 | break;
69 | case JTCalendarWeekDayFormatFull:
70 | days = [[dateFormatter standaloneWeekdaySymbols] mutableCopy];
71 | break;
72 | }
73 |
74 | for(NSInteger i = 0; i < days.count; ++i){
75 | NSString *day = days[i];
76 | [days replaceObjectAtIndex:i withObject:[day uppercaseString]];
77 | }
78 |
79 | // Redorder days for be conform to calendar
80 | {
81 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
82 | NSUInteger firstWeekday = (calendar.firstWeekday + 6) % 7; // Sunday == 1, Saturday == 7
83 |
84 | for(int i = 0; i < firstWeekday; ++i){
85 | id day = [days firstObject];
86 | [days removeObjectAtIndex:0];
87 | [days addObject:day];
88 | }
89 | }
90 |
91 | cacheDaysOfWeeks = days;
92 | return cacheDaysOfWeeks;
93 | }
94 |
95 | - (void)layoutSubviews
96 | {
97 | CGFloat x = 0;
98 | CGFloat width = self.frame.size.width / 7.;
99 | CGFloat height = self.frame.size.height;
100 |
101 | if(self.calendarManager.calendarAppearance.readFromRightToLeft){
102 | for(UIView *view in [[self.subviews reverseObjectEnumerator] allObjects]){
103 | view.frame = CGRectMake(x, 0, width, height);
104 | x = CGRectGetMaxX(view.frame);
105 | }
106 | }
107 | else{
108 | for(UIView *view in self.subviews){
109 | view.frame = CGRectMake(x, 0, width, height);
110 | x = CGRectGetMaxX(view.frame);
111 | }
112 | }
113 |
114 | // No need to call [super layoutSubviews]
115 | }
116 |
117 | + (void)beforeReloadAppearance
118 | {
119 | cacheDaysOfWeeks = nil;
120 | }
121 |
122 | - (void)reloadAppearance
123 | {
124 | for(int i = 0; i < self.subviews.count; ++i){
125 | UILabel *view = [self.subviews objectAtIndex:i];
126 |
127 | view.font = self.calendarManager.calendarAppearance.weekDayTextFont;
128 | view.textColor = self.calendarManager.calendarAppearance.weekDayTextColor;
129 |
130 | view.text = [[self daysOfWeek] objectAtIndex:i];
131 | }
132 | }
133 |
134 | @end
135 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMenuView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMenuView.h"
9 |
10 | #import "JTCalendar.h"
11 | #import "JTCalendarMenuMonthView.h"
12 |
13 | #define NUMBER_PAGES_LOADED 5 // Must be the same in JTCalendarView, JTCalendarMenuView, JTCalendarContentView
14 |
15 | @interface JTCalendarMenuView(){
16 | NSMutableArray *monthsViews;
17 | }
18 |
19 | @end
20 |
21 | @implementation JTCalendarMenuView
22 |
23 | - (instancetype)initWithFrame:(CGRect)frame
24 | {
25 | self = [super initWithFrame:frame];
26 | if(!self){
27 | return nil;
28 | }
29 |
30 | [self commonInit];
31 |
32 | return self;
33 | }
34 |
35 | - (id)initWithCoder:(NSCoder *)aDecoder
36 | {
37 | self = [super initWithCoder:aDecoder];
38 | if(!self){
39 | return nil;
40 | }
41 |
42 | [self commonInit];
43 |
44 | return self;
45 | }
46 |
47 | - (void)commonInit
48 | {
49 | monthsViews = [NSMutableArray new];
50 |
51 | self.showsHorizontalScrollIndicator = NO;
52 | self.showsVerticalScrollIndicator = NO;
53 | self.pagingEnabled = YES;
54 | self.clipsToBounds = YES;
55 |
56 | for(int i = 0; i < NUMBER_PAGES_LOADED; ++i){
57 | JTCalendarMenuMonthView *monthView = [JTCalendarMenuMonthView new];
58 |
59 | [self addSubview:monthView];
60 | [monthsViews addObject:monthView];
61 | }
62 | }
63 |
64 | - (void)layoutSubviews
65 | {
66 | [self configureConstraintsForSubviews];
67 |
68 | [super layoutSubviews];
69 | }
70 |
71 | - (void)configureConstraintsForSubviews
72 | {
73 | self.contentOffset = CGPointMake(self.contentOffset.x, 0); // Prevent bug when contentOffset.y is negative
74 |
75 | CGFloat x = 0;
76 | CGFloat width = self.frame.size.width;
77 | CGFloat height = self.frame.size.height;
78 |
79 | if(self.calendarManager.calendarAppearance.ratioContentMenu != 1.){
80 | width = self.frame.size.width / self.calendarManager.calendarAppearance.ratioContentMenu;
81 | x = (self.frame.size.width - width) / 2.;
82 | }
83 |
84 | if(self.calendarManager.calendarAppearance.readFromRightToLeft){
85 | for(UIView *view in [[monthsViews reverseObjectEnumerator] allObjects]){
86 | view.frame = CGRectMake(x, 0, width, height);
87 | x = CGRectGetMaxX(view.frame);
88 | }
89 | }
90 | else{
91 | for(UIView *view in monthsViews){
92 | view.frame = CGRectMake(x, 0, width, height);
93 | x = CGRectGetMaxX(view.frame);
94 | }
95 | }
96 |
97 | self.contentSize = CGSizeMake(width * NUMBER_PAGES_LOADED, height);
98 | }
99 |
100 | - (void)setCurrentDate:(NSDate *)currentDate
101 | {
102 | self->_currentDate = currentDate;
103 |
104 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
105 | NSDateComponents *dayComponent = [NSDateComponents new];
106 |
107 | for(int i = 0; i < NUMBER_PAGES_LOADED; ++i){
108 | JTCalendarMenuMonthView *monthView = monthsViews[i];
109 |
110 | dayComponent.month = i - (NUMBER_PAGES_LOADED / 2);
111 | NSDate *monthDate = [calendar dateByAddingComponents:dayComponent toDate:self.currentDate options:0];
112 | [monthView setCurrentDate:monthDate];
113 | }
114 | }
115 |
116 | #pragma mark - JTCalendarManager
117 |
118 | - (void)setCalendarManager:(JTCalendar *)calendarManager
119 | {
120 | self->_calendarManager = calendarManager;
121 |
122 | for(JTCalendarMenuMonthView *view in monthsViews){
123 | [view setCalendarManager:calendarManager];
124 | }
125 | }
126 |
127 | - (void)reloadAppearance
128 | {
129 | self.scrollEnabled = !self.calendarManager.calendarAppearance.isWeekMode;
130 |
131 | [self configureConstraintsForSubviews];
132 | for(JTCalendarMenuMonthView *view in monthsViews){
133 | [view reloadAppearance];
134 | }
135 | }
136 |
137 | @end
138 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMonthWeekDaysView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthWeekDaysView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMonthWeekDaysView.h"
9 |
10 | @implementation JTCalendarMonthWeekDaysView
11 |
12 | static NSArray *cacheDaysOfWeeks;
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame
15 | {
16 | self = [super initWithFrame:frame];
17 | if(!self){
18 | return nil;
19 | }
20 |
21 | [self commonInit];
22 |
23 | return self;
24 | }
25 |
26 | - (id)initWithCoder:(NSCoder *)aDecoder
27 | {
28 | self = [super initWithCoder:aDecoder];
29 | if(!self){
30 | return nil;
31 | }
32 |
33 | [self commonInit];
34 |
35 | return self;
36 | }
37 |
38 | - (void)commonInit
39 | {
40 | for(NSString *day in [self daysOfWeek]){
41 | UILabel *view = [UILabel new];
42 |
43 | view.font = self.calendarManager.calendarAppearance.weekDayTextFont;
44 | view.textColor = self.calendarManager.calendarAppearance.weekDayTextColor;
45 |
46 | view.textAlignment = NSTextAlignmentCenter;
47 | view.text = day;
48 |
49 | [self addSubview:view];
50 | }
51 | }
52 |
53 | - (NSArray *)daysOfWeek
54 | {
55 | if(cacheDaysOfWeeks){
56 | return cacheDaysOfWeeks;
57 | }
58 |
59 | NSDateFormatter *dateFormatter = [NSDateFormatter new];
60 | NSMutableArray *days = [[dateFormatter standaloneWeekdaySymbols] mutableCopy];
61 |
62 | // Redorder days for be conform to calendar
63 | {
64 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
65 | NSUInteger firstWeekday = (calendar.firstWeekday + 6) % 7; // Sunday == 1, Saturday == 7
66 |
67 | for(int i = 0; i < firstWeekday; ++i){
68 | id day = [days firstObject];
69 | [days removeObjectAtIndex:0];
70 | [days addObject:day];
71 | }
72 | }
73 |
74 | switch(self.calendarManager.calendarAppearance.weekDayFormat){
75 | case JTCalendarWeekDayFormatSingle:
76 | for(NSInteger i = 0; i < days.count; ++i){
77 | NSString *day = days[i];
78 | [days replaceObjectAtIndex:i withObject:[[day uppercaseString] substringToIndex:1]];
79 | }
80 | break;
81 | case JTCalendarWeekDayFormatShort:
82 | for(NSInteger i = 0; i < days.count; ++i){
83 | NSString *day = days[i];
84 | NSLog(@"%@",[day uppercaseString]);
85 | [days replaceObjectAtIndex:i withObject:[[day uppercaseString] substringFromIndex:2]];
86 | }
87 | break;
88 | case JTCalendarWeekDayFormatFull:
89 | for(NSInteger i = 0; i < days.count; ++i){
90 | NSString *day = days[i];
91 | [days replaceObjectAtIndex:i withObject:[day uppercaseString]];
92 | }
93 | break;
94 | }
95 |
96 | cacheDaysOfWeeks = days;
97 | return cacheDaysOfWeeks;
98 | }
99 |
100 | - (void)layoutSubviews
101 | {
102 | CGFloat x = 0;
103 | CGFloat width = self.frame.size.width / 7.;
104 | CGFloat height = self.frame.size.height;
105 |
106 | for(UIView *view in self.subviews){
107 | view.frame = CGRectMake(x, 0, width, height);
108 | x = CGRectGetMaxX(view.frame);
109 | }
110 |
111 | // No need to call [super layoutSubviews]
112 | }
113 |
114 | + (void)beforeReloadAppearance
115 | {
116 | cacheDaysOfWeeks = nil;
117 | }
118 |
119 | - (void)reloadAppearance
120 | {
121 | for(int i = 0; i < self.subviews.count; ++i){
122 | UILabel *view = [self.subviews objectAtIndex:i];
123 |
124 | view.font = self.calendarManager.calendarAppearance.weekDayTextFont;
125 | view.textColor = self.calendarManager.calendarAppearance.weekDayTextColor;
126 |
127 | view.text = [[self daysOfWeek] objectAtIndex:i];
128 | }
129 | }
130 |
131 | @end
132 |
133 | // 版权属于原作者
134 | // http://code4app.com (cn) http://code4app.net (en)
135 | // 发布代码于最专业的源码分享网站: Code4App.com
136 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/View+MASShorthandAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+MASShorthandAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 22/07/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "View+MASAdditions.h"
10 |
11 | #ifdef MAS_SHORTHAND
12 |
13 | /**
14 | * Shorthand view additions without the 'mas_' prefixes,
15 | * only enabled if MAS_SHORTHAND is defined
16 | */
17 | @interface MAS_VIEW (MASShorthandAdditions)
18 |
19 | @property (nonatomic, strong, readonly) MASViewAttribute *left;
20 | @property (nonatomic, strong, readonly) MASViewAttribute *top;
21 | @property (nonatomic, strong, readonly) MASViewAttribute *right;
22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *width;
26 | @property (nonatomic, strong, readonly) MASViewAttribute *height;
27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX;
28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY;
29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline;
30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr);
31 |
32 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
33 |
34 | @property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline;
35 | @property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline;
36 |
37 | #endif
38 |
39 | #if TARGET_OS_IPHONE || TARGET_OS_TV
40 |
41 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin;
42 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin;
43 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin;
44 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin;
45 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin;
46 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin;
47 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins;
48 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins;
49 |
50 | #endif
51 |
52 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
53 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
54 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
55 |
56 | @end
57 |
58 | #define MAS_ATTR_FORWARD(attr) \
59 | - (MASViewAttribute *)attr { \
60 | return [self mas_##attr]; \
61 | }
62 |
63 | @implementation MAS_VIEW (MASShorthandAdditions)
64 |
65 | MAS_ATTR_FORWARD(top);
66 | MAS_ATTR_FORWARD(left);
67 | MAS_ATTR_FORWARD(bottom);
68 | MAS_ATTR_FORWARD(right);
69 | MAS_ATTR_FORWARD(leading);
70 | MAS_ATTR_FORWARD(trailing);
71 | MAS_ATTR_FORWARD(width);
72 | MAS_ATTR_FORWARD(height);
73 | MAS_ATTR_FORWARD(centerX);
74 | MAS_ATTR_FORWARD(centerY);
75 | MAS_ATTR_FORWARD(baseline);
76 |
77 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
78 |
79 | MAS_ATTR_FORWARD(firstBaseline);
80 | MAS_ATTR_FORWARD(lastBaseline);
81 |
82 | #endif
83 |
84 | #if TARGET_OS_IPHONE || TARGET_OS_TV
85 |
86 | MAS_ATTR_FORWARD(leftMargin);
87 | MAS_ATTR_FORWARD(rightMargin);
88 | MAS_ATTR_FORWARD(topMargin);
89 | MAS_ATTR_FORWARD(bottomMargin);
90 | MAS_ATTR_FORWARD(leadingMargin);
91 | MAS_ATTR_FORWARD(trailingMargin);
92 | MAS_ATTR_FORWARD(centerXWithinMargins);
93 | MAS_ATTR_FORWARD(centerYWithinMargins);
94 |
95 | #endif
96 |
97 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute {
98 | return [self mas_attribute];
99 | }
100 |
101 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
102 | return [self mas_makeConstraints:block];
103 | }
104 |
105 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
106 | return [self mas_updateConstraints:block];
107 | }
108 |
109 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
110 | return [self mas_remakeConstraints:block];
111 | }
112 |
113 | @end
114 |
115 | #endif
116 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/View+MASAdditions.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+MASAdditions.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASUtilities.h"
10 | #import "MASConstraintMaker.h"
11 | #import "MASViewAttribute.h"
12 |
13 | /**
14 | * Provides constraint maker block
15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs
16 | */
17 | @interface MAS_VIEW (MASAdditions)
18 |
19 | /**
20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute
21 | */
22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left;
23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top;
24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right;
25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom;
26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading;
27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing;
28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width;
29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height;
30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX;
31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY;
32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline;
33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr);
34 |
35 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
36 |
37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline;
38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline;
39 |
40 | #endif
41 |
42 | #if TARGET_OS_IPHONE || TARGET_OS_TV
43 |
44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
45 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
46 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
47 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
48 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
49 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
50 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
51 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
52 |
53 | #endif
54 |
55 | /**
56 | * a key to associate with this view
57 | */
58 | @property (nonatomic, strong) id mas_key;
59 |
60 | /**
61 | * Finds the closest common superview between this view and another view
62 | *
63 | * @param view other view
64 | *
65 | * @return returns nil if common superview could not be found
66 | */
67 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view;
68 |
69 | /**
70 | * Creates a MASConstraintMaker with the callee view.
71 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing
72 | *
73 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
74 | *
75 | * @return Array of created MASConstraints
76 | */
77 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block;
78 |
79 | /**
80 | * Creates a MASConstraintMaker with the callee view.
81 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
82 | * If an existing constraint exists then it will be updated instead.
83 | *
84 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
85 | *
86 | * @return Array of created/updated MASConstraints
87 | */
88 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block;
89 |
90 | /**
91 | * Creates a MASConstraintMaker with the callee view.
92 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
93 | * All constraints previously installed for the view will be removed.
94 | *
95 | * @param block scope within which you can build up the constraints which you wish to apply to the view.
96 | *
97 | * @return Array of created/updated MASConstraints
98 | */
99 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block;
100 |
101 | @end
102 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarAppearance.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarAppearance.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarAppearance.h"
9 |
10 | #import "JTCalendar.h"
11 |
12 | @implementation JTCalendarAppearance
13 |
14 | - (instancetype)init
15 | {
16 | self = [super init];
17 | if(!self){
18 | return nil;
19 | }
20 |
21 | [self setDefaultValues];
22 |
23 | return self;
24 | }
25 |
26 | - (void)setDefaultValues
27 | {
28 | self.isWeekMode = NO;
29 |
30 | self.weekDayFormat = JTCalendarWeekDayFormatShort;
31 | self.useCacheSystem = YES;
32 | self.focusSelectedDayChangeMode = NO;
33 |
34 | self.ratioContentMenu = 2.;
35 | self.autoChangeMonth = YES;
36 |
37 | self.dayCircleRatio = 1.;
38 | self.dayDotRatio = 1. / 9.;
39 |
40 | self.menuMonthTextFont = [UIFont systemFontOfSize:17.];
41 | self.weekDayTextFont = [UIFont systemFontOfSize:11];
42 | self.dayTextFont = [UIFont systemFontOfSize:[UIFont systemFontSize]];
43 |
44 | self.dayFormat = @"dd";
45 |
46 | // Day Background and Border
47 | self.dayBackgroundColor = [UIColor clearColor];
48 | self.dayBorderWidth = 0.0f;
49 | self.dayBorderColor = [UIColor clearColor];
50 |
51 | self.menuMonthTextColor = [UIColor blackColor];
52 | self.weekDayTextColor = [UIColor colorWithRed:152./256. green:147./256. blue:157./256. alpha:1.];
53 |
54 | [self setDayDotColorForAll:[UIColor colorWithRed:43./256. green:88./256. blue:134./256. alpha:1.]];
55 | [self setDayTextColorForAll:[UIColor blackColor]];
56 |
57 | self.dayTextColorOtherMonth = [UIColor colorWithRed:152./256. green:147./256. blue:157./256. alpha:1.];
58 |
59 | self.dayCircleColorSelected = [UIColor redColor];
60 | self.dayTextColorSelected = [UIColor whiteColor];
61 | self.dayDotColorSelected = [UIColor whiteColor];
62 |
63 | self.dayCircleColorSelectedOtherMonth = self.dayCircleColorSelected;
64 | self.dayTextColorSelectedOtherMonth = self.dayTextColorSelected;
65 | self.dayDotColorSelectedOtherMonth = self.dayDotColorSelected;
66 |
67 | self.dayCircleColorToday = [UIColor colorWithRed:0x33/256. green:0xB3/256. blue:0xEC/256. alpha:.5];
68 | self.dayTextColorToday = [UIColor whiteColor];
69 | self.dayDotColorToday = [UIColor whiteColor];
70 |
71 | self.dayCircleColorTodayOtherMonth = self.dayCircleColorToday;
72 | self.dayTextColorTodayOtherMonth = self.dayTextColorToday;
73 | self.dayDotColorTodayOtherMonth = self.dayDotColorToday;
74 |
75 | self.monthBlock = ^NSString *(NSDate *date, JTCalendar *jt_calendar){
76 | NSCalendar *calendar = jt_calendar.calendarAppearance.calendar;
77 | NSDateComponents *comps = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth fromDate:date];
78 | NSInteger currentMonthIndex = comps.month;
79 |
80 | static NSDateFormatter *dateFormatter;
81 | if(!dateFormatter){
82 | dateFormatter = [NSDateFormatter new];
83 | dateFormatter.timeZone = jt_calendar.calendarAppearance.calendar.timeZone;
84 | }
85 |
86 | while(currentMonthIndex <= 0){
87 | currentMonthIndex += 12;
88 | }
89 |
90 | return [[dateFormatter standaloneMonthSymbols][currentMonthIndex - 1] capitalizedString];
91 | };
92 | }
93 |
94 | - (NSCalendar *)calendar
95 | {
96 | static NSCalendar *calendar;
97 | static dispatch_once_t once;
98 |
99 | dispatch_once(&once, ^{
100 | #ifdef __IPHONE_8_0
101 | calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
102 | #else
103 | calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
104 | #endif
105 | calendar.timeZone = [NSTimeZone localTimeZone];
106 | });
107 |
108 | return calendar;
109 | }
110 |
111 | - (void)setDayDotColorForAll:(UIColor *)dotColor
112 | {
113 | self.dayDotColor = dotColor;
114 | self.dayDotColorSelected = dotColor;
115 |
116 | self.dayDotColorOtherMonth = dotColor;
117 | self.dayDotColorSelectedOtherMonth = dotColor;
118 |
119 | self.dayDotColorToday = dotColor;
120 | self.dayDotColorTodayOtherMonth = dotColor;
121 | }
122 |
123 | - (void)setDayTextColorForAll:(UIColor *)textColor
124 | {
125 | self.dayTextColor = textColor;
126 | self.dayTextColorSelected = textColor;
127 |
128 | self.dayTextColorOtherMonth = textColor;
129 | self.dayTextColorSelectedOtherMonth = textColor;
130 |
131 | self.dayTextColorToday = textColor;
132 | self.dayTextColorTodayOtherMonth = textColor;
133 | }
134 |
135 | @end
136 |
--------------------------------------------------------------------------------
/CCTimePickerDemo.xcodeproj/xcuserdata/ehome.xcuserdatad/xcschemes/CCTimePickerDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
43 |
49 |
50 |
51 |
52 |
53 |
59 |
60 |
61 |
62 |
63 |
64 |
74 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
95 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarMonthView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMonthView.h"
9 |
10 | #import "JTCalendarMonthWeekDaysView.h"
11 | #import "JTCalendarWeekView.h"
12 |
13 | #define WEEKS_TO_DISPLAY 6
14 |
15 | @interface JTCalendarMonthView (){
16 | JTCalendarMonthWeekDaysView *weekdaysView;
17 | NSArray *weeksViews;
18 |
19 | NSUInteger currentMonthIndex;
20 | BOOL cacheLastWeekMode; // Avoid some operations
21 | };
22 |
23 | @end
24 |
25 | @implementation JTCalendarMonthView
26 |
27 | - (instancetype)initWithFrame:(CGRect)frame
28 | {
29 | self = [super initWithFrame:frame];
30 | if(!self){
31 | return nil;
32 | }
33 |
34 | [self commonInit];
35 |
36 | return self;
37 | }
38 |
39 | - (id)initWithCoder:(NSCoder *)aDecoder
40 | {
41 | self = [super initWithCoder:aDecoder];
42 | if(!self){
43 | return nil;
44 | }
45 |
46 | [self commonInit];
47 |
48 | return self;
49 | }
50 |
51 | - (void)commonInit
52 | {
53 | NSMutableArray *views = [NSMutableArray new];
54 |
55 | {
56 | weekdaysView = [JTCalendarMonthWeekDaysView new];
57 | [self addSubview:weekdaysView];
58 | }
59 |
60 | for(int i = 0; i < WEEKS_TO_DISPLAY; ++i){
61 | UIView *view = [JTCalendarWeekView new];
62 |
63 | [views addObject:view];
64 | [self addSubview:view];
65 | }
66 |
67 | weeksViews = views;
68 |
69 | cacheLastWeekMode = self.calendarManager.calendarAppearance.isWeekMode;
70 | }
71 |
72 | - (void)layoutSubviews
73 | {
74 | [self configureConstraintsForSubviews];
75 |
76 | [super layoutSubviews];
77 | }
78 |
79 | - (void)configureConstraintsForSubviews
80 | {
81 | CGFloat weeksToDisplay;
82 |
83 | if(cacheLastWeekMode){
84 | weeksToDisplay = 2.;
85 | }
86 | else{
87 | weeksToDisplay = (CGFloat)(WEEKS_TO_DISPLAY + 1); // + 1 for weekDays
88 | }
89 |
90 | CGFloat y = 0;
91 | CGFloat width = self.frame.size.width;
92 | CGFloat height = self.frame.size.height / weeksToDisplay;
93 |
94 | for(int i = 0; i < self.subviews.count; ++i){
95 | UIView *view = self.subviews[i];
96 |
97 | view.frame = CGRectMake(0, y, width, height);
98 | y = CGRectGetMaxY(view.frame);
99 |
100 | if(cacheLastWeekMode && i == weeksToDisplay - 1){
101 | height = 0.;
102 | }
103 | }
104 | }
105 |
106 | - (void)setBeginningOfMonth:(NSDate *)date
107 | {
108 | NSDate *currentDate = date;
109 |
110 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
111 |
112 | {
113 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth|NSCalendarUnitDay fromDate:currentDate];
114 |
115 | currentMonthIndex = comps.month;
116 |
117 | // Hack
118 | if(comps.day > 7){
119 | currentMonthIndex = (currentMonthIndex % 12) + 1;
120 | }
121 | }
122 |
123 | for(JTCalendarWeekView *view in weeksViews){
124 | view.currentMonthIndex = currentMonthIndex;
125 | [view setBeginningOfWeek:currentDate];
126 |
127 | NSDateComponents *dayComponent = [NSDateComponents new];
128 | dayComponent.day = 7;
129 |
130 | currentDate = [calendar dateByAddingComponents:dayComponent toDate:currentDate options:0];
131 |
132 | // Doesn't need to do other weeks
133 | if(self.calendarManager.calendarAppearance.isWeekMode){
134 | break;
135 | }
136 | }
137 | }
138 |
139 | #pragma mark - JTCalendarManager
140 |
141 | - (void)setCalendarManager:(JTCalendar *)calendarManager
142 | {
143 | self->_calendarManager = calendarManager;
144 |
145 | [weekdaysView setCalendarManager:calendarManager];
146 | for(JTCalendarWeekView *view in weeksViews){
147 | [view setCalendarManager:calendarManager];
148 | }
149 | }
150 |
151 | - (void)reloadData
152 | {
153 | for(JTCalendarWeekView *view in weeksViews){
154 | [view reloadData];
155 |
156 | // Doesn't need to do other weeks
157 | if(self.calendarManager.calendarAppearance.isWeekMode){
158 | break;
159 | }
160 | }
161 | }
162 |
163 | - (void)reloadAppearance
164 | {
165 | if(cacheLastWeekMode != self.calendarManager.calendarAppearance.isWeekMode){
166 | cacheLastWeekMode = self.calendarManager.calendarAppearance.isWeekMode;
167 | [self configureConstraintsForSubviews];
168 | }
169 |
170 | [JTCalendarMonthWeekDaysView beforeReloadAppearance];
171 | [weekdaysView reloadAppearance];
172 |
173 | for(JTCalendarWeekView *view in weeksViews){
174 | [view reloadAppearance];
175 | }
176 | }
177 |
178 | @end
179 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMonthView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMonthView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMonthView.h"
9 |
10 | #import "JTCalendarMonthWeekDaysView.h"
11 | #import "JTCalendarWeekView.h"
12 |
13 | #define WEEKS_TO_DISPLAY 6
14 |
15 | @interface JTCalendarMonthView (){
16 | JTCalendarMonthWeekDaysView *weekdaysView;
17 | NSArray *weeksViews;
18 |
19 | NSUInteger currentMonthIndex;
20 | BOOL cacheLastWeekMode; // Avoid some operations
21 | };
22 |
23 | @end
24 |
25 | @implementation JTCalendarMonthView
26 |
27 | - (instancetype)initWithFrame:(CGRect)frame
28 | {
29 | self = [super initWithFrame:frame];
30 | if(!self){
31 | return nil;
32 | }
33 |
34 | [self commonInit];
35 |
36 | return self;
37 | }
38 |
39 | - (id)initWithCoder:(NSCoder *)aDecoder
40 | {
41 | self = [super initWithCoder:aDecoder];
42 | if(!self){
43 | return nil;
44 | }
45 |
46 | [self commonInit];
47 |
48 | return self;
49 | }
50 |
51 | - (void)commonInit
52 | {
53 | NSMutableArray *views = [NSMutableArray new];
54 |
55 | {
56 | weekdaysView = [JTCalendarMonthWeekDaysView new];
57 | [self addSubview:weekdaysView];
58 | }
59 |
60 | for(int i = 0; i < WEEKS_TO_DISPLAY; ++i){
61 | UIView *view = [JTCalendarWeekView new];
62 |
63 | [views addObject:view];
64 | [self addSubview:view];
65 | }
66 |
67 | weeksViews = views;
68 |
69 | cacheLastWeekMode = self.calendarManager.calendarAppearance.isWeekMode;
70 | }
71 |
72 | - (void)layoutSubviews
73 | {
74 | [self configureConstraintsForSubviews];
75 |
76 | [super layoutSubviews];
77 | }
78 |
79 | - (void)configureConstraintsForSubviews
80 | {
81 | CGFloat weeksToDisplay;
82 |
83 | if(cacheLastWeekMode){
84 | weeksToDisplay = 2.;
85 | }
86 | else{
87 | weeksToDisplay = (CGFloat)(WEEKS_TO_DISPLAY + 1); // + 1 for weekDays
88 | }
89 |
90 | CGFloat y = 0;
91 | CGFloat width = self.frame.size.width;
92 | CGFloat height = self.frame.size.height / weeksToDisplay;
93 |
94 | for(int i = 0; i < self.subviews.count; ++i){
95 | UIView *view = self.subviews[i];
96 |
97 | view.frame = CGRectMake(0, y, width, height);
98 | y = CGRectGetMaxY(view.frame);
99 |
100 | if(cacheLastWeekMode && i == weeksToDisplay - 1){
101 | height = 0.;
102 | }
103 | }
104 | }
105 |
106 | - (void)setBeginningOfMonth:(NSDate *)date
107 | {
108 | NSDate *currentDate = date;
109 |
110 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
111 |
112 | {
113 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth|NSCalendarUnitDay fromDate:currentDate];
114 |
115 | currentMonthIndex = comps.month;
116 |
117 | // Hack
118 | if(comps.day > 7){
119 | currentMonthIndex = (currentMonthIndex % 12) + 1;
120 | }
121 | }
122 |
123 | for(JTCalendarWeekView *view in weeksViews){
124 | view.currentMonthIndex = currentMonthIndex;
125 | [view setBeginningOfWeek:currentDate];
126 |
127 | NSDateComponents *dayComponent = [NSDateComponents new];
128 | dayComponent.day = 7;
129 |
130 | currentDate = [calendar dateByAddingComponents:dayComponent toDate:currentDate options:0];
131 |
132 | // Doesn't need to do other weeks
133 | if(self.calendarManager.calendarAppearance.isWeekMode){
134 | break;
135 | }
136 | }
137 | }
138 |
139 | #pragma mark - JTCalendarManager
140 |
141 | - (void)setCalendarManager:(JTCalendar *)calendarManager
142 | {
143 | self->_calendarManager = calendarManager;
144 |
145 | [weekdaysView setCalendarManager:calendarManager];
146 | for(JTCalendarWeekView *view in weeksViews){
147 | [view setCalendarManager:calendarManager];
148 | }
149 | }
150 |
151 | - (void)reloadData
152 | {
153 | for(JTCalendarWeekView *view in weeksViews){
154 | [view reloadData];
155 |
156 | // Doesn't need to do other weeks
157 | if(self.calendarManager.calendarAppearance.isWeekMode){
158 | break;
159 | }
160 | }
161 | }
162 |
163 | - (void)reloadAppearance
164 | {
165 | if(cacheLastWeekMode != self.calendarManager.calendarAppearance.isWeekMode){
166 | cacheLastWeekMode = self.calendarManager.calendarAppearance.isWeekMode;
167 | [self configureConstraintsForSubviews];
168 | }
169 |
170 | [JTCalendarMonthWeekDaysView beforeReloadAppearance];
171 | [weekdaysView reloadAppearance];
172 |
173 | for(JTCalendarWeekView *view in weeksViews){
174 | [view reloadAppearance];
175 | }
176 | }
177 |
178 | @end
179 |
180 | // 版权属于原作者
181 | // http://code4app.com (cn) http://code4app.net (en)
182 | // 发布代码于最专业的源码分享网站: Code4App.com
183 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASCompositeConstraint.m:
--------------------------------------------------------------------------------
1 | //
2 | // MASCompositeConstraint.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 21/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASCompositeConstraint.h"
10 | #import "MASConstraint+Private.h"
11 |
12 | @interface MASCompositeConstraint ()
13 |
14 | @property (nonatomic, strong) id mas_key;
15 | @property (nonatomic, strong) NSMutableArray *childConstraints;
16 |
17 | @end
18 |
19 | @implementation MASCompositeConstraint
20 |
21 | - (id)initWithChildren:(NSArray *)children {
22 | self = [super init];
23 | if (!self) return nil;
24 |
25 | _childConstraints = [children mutableCopy];
26 | for (MASConstraint *constraint in _childConstraints) {
27 | constraint.delegate = self;
28 | }
29 |
30 | return self;
31 | }
32 |
33 | #pragma mark - MASConstraintDelegate
34 |
35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
36 | NSUInteger index = [self.childConstraints indexOfObject:constraint];
37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint];
39 | }
40 |
41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
42 | id strongDelegate = self.delegate;
43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
44 | newConstraint.delegate = self;
45 | [self.childConstraints addObject:newConstraint];
46 | return newConstraint;
47 | }
48 |
49 | #pragma mark - NSLayoutConstraint multiplier proxies
50 |
51 | - (MASConstraint * (^)(CGFloat))multipliedBy {
52 | return ^id(CGFloat multiplier) {
53 | for (MASConstraint *constraint in self.childConstraints) {
54 | constraint.multipliedBy(multiplier);
55 | }
56 | return self;
57 | };
58 | }
59 |
60 | - (MASConstraint * (^)(CGFloat))dividedBy {
61 | return ^id(CGFloat divider) {
62 | for (MASConstraint *constraint in self.childConstraints) {
63 | constraint.dividedBy(divider);
64 | }
65 | return self;
66 | };
67 | }
68 |
69 | #pragma mark - MASLayoutPriority proxy
70 |
71 | - (MASConstraint * (^)(MASLayoutPriority))priority {
72 | return ^id(MASLayoutPriority priority) {
73 | for (MASConstraint *constraint in self.childConstraints) {
74 | constraint.priority(priority);
75 | }
76 | return self;
77 | };
78 | }
79 |
80 | #pragma mark - NSLayoutRelation proxy
81 |
82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
83 | return ^id(id attr, NSLayoutRelation relation) {
84 | for (MASConstraint *constraint in self.childConstraints.copy) {
85 | constraint.equalToWithRelation(attr, relation);
86 | }
87 | return self;
88 | };
89 | }
90 |
91 | #pragma mark - attribute chaining
92 |
93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
95 | return self;
96 | }
97 |
98 | #pragma mark - Animator proxy
99 |
100 | #if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
101 |
102 | - (MASConstraint *)animator {
103 | for (MASConstraint *constraint in self.childConstraints) {
104 | [constraint animator];
105 | }
106 | return self;
107 | }
108 |
109 | #endif
110 |
111 | #pragma mark - debug helpers
112 |
113 | - (MASConstraint * (^)(id))key {
114 | return ^id(id key) {
115 | self.mas_key = key;
116 | int i = 0;
117 | for (MASConstraint *constraint in self.childConstraints) {
118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]);
119 | }
120 | return self;
121 | };
122 | }
123 |
124 | #pragma mark - NSLayoutConstraint constant setters
125 |
126 | - (void)setInsets:(MASEdgeInsets)insets {
127 | for (MASConstraint *constraint in self.childConstraints) {
128 | constraint.insets = insets;
129 | }
130 | }
131 |
132 | - (void)setOffset:(CGFloat)offset {
133 | for (MASConstraint *constraint in self.childConstraints) {
134 | constraint.offset = offset;
135 | }
136 | }
137 |
138 | - (void)setSizeOffset:(CGSize)sizeOffset {
139 | for (MASConstraint *constraint in self.childConstraints) {
140 | constraint.sizeOffset = sizeOffset;
141 | }
142 | }
143 |
144 | - (void)setCenterOffset:(CGPoint)centerOffset {
145 | for (MASConstraint *constraint in self.childConstraints) {
146 | constraint.centerOffset = centerOffset;
147 | }
148 | }
149 |
150 | #pragma mark - MASConstraint
151 |
152 | - (void)activate {
153 | for (MASConstraint *constraint in self.childConstraints) {
154 | [constraint activate];
155 | }
156 | }
157 |
158 | - (void)deactivate {
159 | for (MASConstraint *constraint in self.childConstraints) {
160 | [constraint deactivate];
161 | }
162 | }
163 |
164 | - (void)install {
165 | for (MASConstraint *constraint in self.childConstraints) {
166 | constraint.updateExisting = self.updateExisting;
167 | [constraint install];
168 | }
169 | }
170 |
171 | - (void)uninstall {
172 | for (MASConstraint *constraint in self.childConstraints) {
173 | [constraint uninstall];
174 | }
175 | }
176 |
177 | @end
178 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/JTCalendar/JTCalendarContentView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarContentView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarContentView.h"
9 |
10 | #import "JTCalendar.h"
11 |
12 | #import "JTCalendarMonthView.h"
13 | #import "JTCalendarWeekView.h"
14 |
15 | #define NUMBER_PAGES_LOADED 5 // Must be the same in JTCalendarView, JTCalendarMenuView, JTCalendarContentView
16 |
17 | @interface JTCalendarContentView(){
18 | NSMutableArray *monthsViews;
19 | }
20 |
21 | @end
22 |
23 | @implementation JTCalendarContentView
24 |
25 | - (instancetype)initWithFrame:(CGRect)frame
26 | {
27 | self = [super initWithFrame:frame];
28 | if(!self){
29 | return nil;
30 | }
31 |
32 | [self commonInit];
33 |
34 | return self;
35 | }
36 |
37 | - (id)initWithCoder:(NSCoder *)aDecoder
38 | {
39 | self = [super initWithCoder:aDecoder];
40 | if(!self){
41 | return nil;
42 | }
43 |
44 | [self commonInit];
45 |
46 | return self;
47 | }
48 |
49 | - (void)commonInit
50 | {
51 | monthsViews = [NSMutableArray new];
52 |
53 | self.showsHorizontalScrollIndicator = NO;
54 | self.showsVerticalScrollIndicator = NO;
55 | self.pagingEnabled = YES;
56 | self.clipsToBounds = YES;
57 |
58 | for(int i = 0; i < NUMBER_PAGES_LOADED; ++i){
59 | JTCalendarMonthView *monthView = [JTCalendarMonthView new];
60 | [self addSubview:monthView];
61 | [monthsViews addObject:monthView];
62 | }
63 | }
64 |
65 | - (void)layoutSubviews
66 | {
67 | [self configureConstraintsForSubviews];
68 |
69 | [super layoutSubviews];
70 | }
71 |
72 | - (void)configureConstraintsForSubviews
73 | {
74 | self.contentOffset = CGPointMake(self.contentOffset.x, 0); // Prevent bug when contentOffset.y is negative
75 |
76 | CGFloat x = 0;
77 | CGFloat width = self.frame.size.width;
78 | CGFloat height = self.frame.size.height;
79 |
80 | if(self.calendarManager.calendarAppearance.readFromRightToLeft){
81 | for(UIView *view in [[monthsViews reverseObjectEnumerator] allObjects]){
82 | view.frame = CGRectMake(x, 0, width, height);
83 | x = CGRectGetMaxX(view.frame);
84 | }
85 | }
86 | else{
87 | for(UIView *view in monthsViews){
88 | view.frame = CGRectMake(x, 0, width, height);
89 | x = CGRectGetMaxX(view.frame);
90 | }
91 | }
92 |
93 | self.contentSize = CGSizeMake(width * NUMBER_PAGES_LOADED, height);
94 | }
95 |
96 | - (void)setCurrentDate:(NSDate *)currentDate
97 | {
98 | self->_currentDate = currentDate;
99 |
100 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
101 |
102 | for(int i = 0; i < NUMBER_PAGES_LOADED; ++i){
103 | JTCalendarMonthView *monthView = monthsViews[i];
104 |
105 | NSDateComponents *dayComponent = [NSDateComponents new];
106 |
107 | if(!self.calendarManager.calendarAppearance.isWeekMode){
108 | dayComponent.month = i - (NUMBER_PAGES_LOADED / 2);
109 |
110 | NSDate *monthDate = [calendar dateByAddingComponents:dayComponent toDate:self.currentDate options:0];
111 | monthDate = [self beginningOfMonth:monthDate];
112 | [monthView setBeginningOfMonth:monthDate];
113 | }
114 | else{
115 | dayComponent.day = 7 * (i - (NUMBER_PAGES_LOADED / 2));
116 |
117 | NSDate *monthDate = [calendar dateByAddingComponents:dayComponent toDate:self.currentDate options:0];
118 | monthDate = [self beginningOfWeek:monthDate];
119 | [monthView setBeginningOfMonth:monthDate];
120 | }
121 | }
122 | }
123 |
124 | - (NSDate *)beginningOfMonth:(NSDate *)date
125 | {
126 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
127 | NSDateComponents *componentsCurrentDate = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitWeekday|NSCalendarUnitWeekOfMonth fromDate:date];
128 |
129 | NSDateComponents *componentsNewDate = [NSDateComponents new];
130 |
131 | componentsNewDate.year = componentsCurrentDate.year;
132 | componentsNewDate.month = componentsCurrentDate.month;
133 | componentsNewDate.weekOfMonth = 1;
134 | componentsNewDate.weekday = calendar.firstWeekday;
135 |
136 | return [calendar dateFromComponents:componentsNewDate];
137 | }
138 |
139 | - (NSDate *)beginningOfWeek:(NSDate *)date
140 | {
141 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
142 | NSDateComponents *componentsCurrentDate = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitWeekday|NSCalendarUnitWeekOfMonth fromDate:date];
143 |
144 | NSDateComponents *componentsNewDate = [NSDateComponents new];
145 |
146 | componentsNewDate.year = componentsCurrentDate.year;
147 | componentsNewDate.month = componentsCurrentDate.month;
148 | componentsNewDate.weekOfMonth = componentsCurrentDate.weekOfMonth;
149 | componentsNewDate.weekday = calendar.firstWeekday;
150 |
151 | return [calendar dateFromComponents:componentsNewDate];
152 | }
153 |
154 | #pragma mark - JTCalendarManager
155 |
156 | - (void)setCalendarManager:(JTCalendar *)calendarManager
157 | {
158 | self->_calendarManager = calendarManager;
159 |
160 | for(JTCalendarMonthView *view in monthsViews){
161 | [view setCalendarManager:calendarManager];
162 | }
163 | }
164 |
165 | - (void)reloadData
166 | {
167 | for(JTCalendarMonthView *monthView in monthsViews){
168 | [monthView reloadData];
169 | }
170 | }
171 |
172 | - (void)reloadAppearance
173 | {
174 | // Fix when change mode during scroll
175 | self.scrollEnabled = YES;
176 |
177 | for(JTCalendarMonthView *monthView in monthsViews){
178 | [monthView reloadAppearance];
179 | }
180 | }
181 |
182 | @end
183 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendarMenuView.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendarMenuView.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendarMenuView.h"
9 |
10 | #import "JTCalendar.h"
11 | #import "JTCalendarMenuMonthView.h"
12 |
13 | #define NUMBER_PAGES_LOADED 5 // Must be the same in JTCalendarView, JTCalendarMenuView, JTCalendarContentView
14 |
15 | @interface JTCalendarMenuView(){
16 | NSMutableArray *monthsViews;
17 | }
18 |
19 | @end
20 |
21 | @implementation JTCalendarMenuView
22 |
23 | - (instancetype)initWithFrame:(CGRect)frame
24 | {
25 | self = [super initWithFrame:frame];
26 | if(!self){
27 | return nil;
28 | }
29 |
30 | [self commonInit];
31 |
32 | return self;
33 | }
34 |
35 | - (id)initWithCoder:(NSCoder *)aDecoder
36 | {
37 | self = [super initWithCoder:aDecoder];
38 | if(!self){
39 | return nil;
40 | }
41 |
42 | [self commonInit];
43 |
44 | return self;
45 | }
46 |
47 | - (void)commonInit
48 | {
49 | monthsViews = [NSMutableArray new];
50 |
51 | self.showsHorizontalScrollIndicator = NO;
52 | self.showsVerticalScrollIndicator = NO;
53 | self.pagingEnabled = YES;
54 |
55 | for(int i = 0; i < NUMBER_PAGES_LOADED; ++i){
56 | JTCalendarMenuMonthView *monthView = [JTCalendarMenuMonthView new];
57 |
58 | [self addSubview:monthView];
59 | [monthsViews addObject:monthView];
60 | }
61 | }
62 |
63 | - (void)layoutSubviews
64 | {
65 | [self configureConstraintsForSubviews];
66 |
67 | [super layoutSubviews];
68 | }
69 |
70 | - (void)configureConstraintsForSubviews
71 | {
72 | self.contentOffset = CGPointMake(self.contentOffset.x, 0); // Prevent bug when contentOffset.y is negative
73 |
74 | CGFloat x = 0;
75 | CGFloat width = self.frame.size.width;
76 | CGFloat height = self.frame.size.height;
77 |
78 | if(self.calendarManager.calendarAppearance.ratioContentMenu != 1.){
79 | width = self.frame.size.width / self.calendarManager.calendarAppearance.ratioContentMenu;
80 | x = (self.frame.size.width - width) / 2.;
81 | }
82 |
83 | for(UIView *view in monthsViews){
84 | view.frame = CGRectMake(x, 0, width, height);
85 | x = CGRectGetMaxX(view.frame);
86 | }
87 |
88 | self.contentSize = CGSizeMake(width * NUMBER_PAGES_LOADED, height);
89 | }
90 |
91 | - (void)setCurrentDate:(NSDate *)currentDate
92 | {
93 | self->_currentDate = currentDate;
94 |
95 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
96 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth fromDate:currentDate];
97 | NSInteger currentMonthIndex = comps.month;
98 |
99 | for(int i = 0; i < NUMBER_PAGES_LOADED; ++i){
100 | JTCalendarMenuMonthView *monthView = monthsViews[i];
101 | NSInteger monthIndex = currentMonthIndex - (NUMBER_PAGES_LOADED / 2) + i;
102 | monthIndex = monthIndex % 12;
103 |
104 | [monthView setMonthIndex:monthIndex];
105 | }
106 | }
107 |
108 | #pragma mark - Load Month
109 |
110 | - (void)loadPreviousMonth
111 | {
112 | JTCalendarMenuMonthView *monthView = [monthsViews lastObject];
113 |
114 | [monthsViews removeLastObject];
115 | [monthsViews insertObject:monthView atIndex:0];
116 |
117 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
118 |
119 | // Update currentDate
120 | {
121 | NSDateComponents *dayComponent = [NSDateComponents new];
122 | dayComponent.month = -1;
123 | self->_currentDate = [calendar dateByAddingComponents:dayComponent toDate:self.currentDate options:0];
124 | }
125 |
126 | // Update monthView
127 | {
128 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth fromDate:self.currentDate];
129 | NSInteger currentMonthIndex = comps.month;
130 |
131 | NSInteger monthIndex = currentMonthIndex - (NUMBER_PAGES_LOADED / 2);
132 | monthIndex = monthIndex % 12;
133 | [monthView setMonthIndex:monthIndex];
134 | }
135 |
136 | [self configureConstraintsForSubviews];
137 | }
138 |
139 | - (void)loadNextMonth
140 | {
141 | JTCalendarMenuMonthView *monthView = [monthsViews firstObject];
142 |
143 | [monthsViews removeObjectAtIndex:0];
144 | [monthsViews addObject:monthView];
145 |
146 | NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
147 |
148 | // Update currentDate
149 | {
150 | NSDateComponents *dayComponent = [NSDateComponents new];
151 | dayComponent.month = 1;
152 | self->_currentDate = [calendar dateByAddingComponents:dayComponent toDate:self.currentDate options:0];
153 | }
154 |
155 | // Update monthView
156 | {
157 | NSDateComponents *comps = [calendar components:NSCalendarUnitMonth fromDate:self.currentDate];
158 | NSInteger currentMonthIndex = comps.month;
159 |
160 | NSInteger monthIndex = currentMonthIndex - (NUMBER_PAGES_LOADED / 2) + (NUMBER_PAGES_LOADED - 1);
161 | monthIndex = monthIndex % 12;
162 | [monthView setMonthIndex:monthIndex];
163 | }
164 |
165 | [self configureConstraintsForSubviews];
166 | }
167 |
168 | #pragma mark - JTCalendarManager
169 |
170 | - (void)setCalendarManager:(JTCalendar *)calendarManager
171 | {
172 | self->_calendarManager = calendarManager;
173 |
174 | for(JTCalendarMenuMonthView *view in monthsViews){
175 | [view setCalendarManager:calendarManager];
176 | }
177 | }
178 |
179 | - (void)reloadAppearance
180 | {
181 | self.scrollEnabled = !self.calendarManager.calendarAppearance.isWeekMode;
182 |
183 | [self configureConstraintsForSubviews];
184 | for(JTCalendarMenuMonthView *view in monthsViews){
185 | [view reloadAppearance];
186 | }
187 | }
188 |
189 | @end
190 |
191 | // 版权属于原作者
192 | // http://code4app.com (cn) http://code4app.net (en)
193 | // 发布代码于最专业的源码分享网站: Code4App.com
194 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/MASConstraintMaker.h:
--------------------------------------------------------------------------------
1 | //
2 | // MASConstraintBuilder.h
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "MASConstraint.h"
10 | #import "MASUtilities.h"
11 |
12 | typedef NS_OPTIONS(NSInteger, MASAttribute) {
13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft,
14 | MASAttributeRight = 1 << NSLayoutAttributeRight,
15 | MASAttributeTop = 1 << NSLayoutAttributeTop,
16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom,
17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading,
18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing,
19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth,
20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight,
21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
24 |
25 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
26 |
27 | MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline,
28 | MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline,
29 |
30 | #endif
31 |
32 | #if TARGET_OS_IPHONE || TARGET_OS_TV
33 |
34 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin,
35 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin,
36 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin,
37 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin,
38 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin,
39 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin,
40 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins,
41 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins,
42 |
43 | #endif
44 |
45 | };
46 |
47 | /**
48 | * Provides factory methods for creating MASConstraints.
49 | * Constraints are collected until they are ready to be installed
50 | *
51 | */
52 | @interface MASConstraintMaker : NSObject
53 |
54 | /**
55 | * The following properties return a new MASViewConstraint
56 | * with the first item set to the makers associated view and the appropriate MASViewAttribute
57 | */
58 | @property (nonatomic, strong, readonly) MASConstraint *left;
59 | @property (nonatomic, strong, readonly) MASConstraint *top;
60 | @property (nonatomic, strong, readonly) MASConstraint *right;
61 | @property (nonatomic, strong, readonly) MASConstraint *bottom;
62 | @property (nonatomic, strong, readonly) MASConstraint *leading;
63 | @property (nonatomic, strong, readonly) MASConstraint *trailing;
64 | @property (nonatomic, strong, readonly) MASConstraint *width;
65 | @property (nonatomic, strong, readonly) MASConstraint *height;
66 | @property (nonatomic, strong, readonly) MASConstraint *centerX;
67 | @property (nonatomic, strong, readonly) MASConstraint *centerY;
68 | @property (nonatomic, strong, readonly) MASConstraint *baseline;
69 |
70 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
71 |
72 | @property (nonatomic, strong, readonly) MASConstraint *firstBaseline;
73 | @property (nonatomic, strong, readonly) MASConstraint *lastBaseline;
74 |
75 | #endif
76 |
77 | #if TARGET_OS_IPHONE || TARGET_OS_TV
78 |
79 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin;
80 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin;
81 | @property (nonatomic, strong, readonly) MASConstraint *topMargin;
82 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin;
83 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin;
84 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin;
85 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins;
86 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins;
87 |
88 | #endif
89 |
90 | /**
91 | * Returns a block which creates a new MASCompositeConstraint with the first item set
92 | * to the makers associated view and children corresponding to the set bits in the
93 | * MASAttribute parameter. Combine multiple attributes via binary-or.
94 | */
95 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs);
96 |
97 | /**
98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges
99 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right)
100 | * with the first item set to the makers associated view
101 | */
102 | @property (nonatomic, strong, readonly) MASConstraint *edges;
103 |
104 | /**
105 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize
106 | * which generates the appropriate MASViewConstraint children (width, height)
107 | * with the first item set to the makers associated view
108 | */
109 | @property (nonatomic, strong, readonly) MASConstraint *size;
110 |
111 | /**
112 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter
113 | * which generates the appropriate MASViewConstraint children (centerX, centerY)
114 | * with the first item set to the makers associated view
115 | */
116 | @property (nonatomic, strong, readonly) MASConstraint *center;
117 |
118 | /**
119 | * Whether or not to check for an existing constraint instead of adding constraint
120 | */
121 | @property (nonatomic, assign) BOOL updateExisting;
122 |
123 | /**
124 | * Whether or not to remove existing constraints prior to installing
125 | */
126 | @property (nonatomic, assign) BOOL removeExisting;
127 |
128 | /**
129 | * initialises the maker with a default view
130 | *
131 | * @param view any MASConstrait are created with this view as the first item
132 | *
133 | * @return a new MASConstraintMaker
134 | */
135 | - (id)initWithView:(MAS_VIEW *)view;
136 |
137 | /**
138 | * Calls install method on any MASConstraints which have been created by this maker
139 | *
140 | * @return an array of all the installed MASConstraints
141 | */
142 | - (NSArray *)install;
143 |
144 | - (MASConstraint * (^)(dispatch_block_t))group;
145 |
146 | @end
147 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/View+MASAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIView+MASAdditions.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 20/07/13.
6 | // Copyright (c) 2013 cloudling. All rights reserved.
7 | //
8 |
9 | #import "View+MASAdditions.h"
10 | #import
11 |
12 | @implementation MAS_VIEW (MASAdditions)
13 |
14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block {
15 | self.translatesAutoresizingMaskIntoConstraints = NO;
16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
17 | block(constraintMaker);
18 | return [constraintMaker install];
19 | }
20 |
21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block {
22 | self.translatesAutoresizingMaskIntoConstraints = NO;
23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
24 | constraintMaker.updateExisting = YES;
25 | block(constraintMaker);
26 | return [constraintMaker install];
27 | }
28 |
29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block {
30 | self.translatesAutoresizingMaskIntoConstraints = NO;
31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
32 | constraintMaker.removeExisting = YES;
33 | block(constraintMaker);
34 | return [constraintMaker install];
35 | }
36 |
37 | #pragma mark - NSLayoutAttribute properties
38 |
39 | - (MASViewAttribute *)mas_left {
40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft];
41 | }
42 |
43 | - (MASViewAttribute *)mas_top {
44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop];
45 | }
46 |
47 | - (MASViewAttribute *)mas_right {
48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight];
49 | }
50 |
51 | - (MASViewAttribute *)mas_bottom {
52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom];
53 | }
54 |
55 | - (MASViewAttribute *)mas_leading {
56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading];
57 | }
58 |
59 | - (MASViewAttribute *)mas_trailing {
60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing];
61 | }
62 |
63 | - (MASViewAttribute *)mas_width {
64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth];
65 | }
66 |
67 | - (MASViewAttribute *)mas_height {
68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight];
69 | }
70 |
71 | - (MASViewAttribute *)mas_centerX {
72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX];
73 | }
74 |
75 | - (MASViewAttribute *)mas_centerY {
76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY];
77 | }
78 |
79 | - (MASViewAttribute *)mas_baseline {
80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline];
81 | }
82 |
83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute
84 | {
85 | return ^(NSLayoutAttribute attr) {
86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr];
87 | };
88 | }
89 |
90 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
91 |
92 | - (MASViewAttribute *)mas_firstBaseline {
93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline];
94 | }
95 | - (MASViewAttribute *)mas_lastBaseline {
96 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline];
97 | }
98 |
99 | #endif
100 |
101 | #if TARGET_OS_IPHONE || TARGET_OS_TV
102 |
103 | - (MASViewAttribute *)mas_leftMargin {
104 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin];
105 | }
106 |
107 | - (MASViewAttribute *)mas_rightMargin {
108 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin];
109 | }
110 |
111 | - (MASViewAttribute *)mas_topMargin {
112 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin];
113 | }
114 |
115 | - (MASViewAttribute *)mas_bottomMargin {
116 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin];
117 | }
118 |
119 | - (MASViewAttribute *)mas_leadingMargin {
120 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin];
121 | }
122 |
123 | - (MASViewAttribute *)mas_trailingMargin {
124 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin];
125 | }
126 |
127 | - (MASViewAttribute *)mas_centerXWithinMargins {
128 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins];
129 | }
130 |
131 | - (MASViewAttribute *)mas_centerYWithinMargins {
132 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins];
133 | }
134 |
135 | #endif
136 |
137 | #pragma mark - associated properties
138 |
139 | - (id)mas_key {
140 | return objc_getAssociatedObject(self, @selector(mas_key));
141 | }
142 |
143 | - (void)setMas_key:(id)key {
144 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
145 | }
146 |
147 | #pragma mark - heirachy
148 |
149 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view {
150 | MAS_VIEW *closestCommonSuperview = nil;
151 |
152 | MAS_VIEW *secondViewSuperview = view;
153 | while (!closestCommonSuperview && secondViewSuperview) {
154 | MAS_VIEW *firstViewSuperview = self;
155 | while (!closestCommonSuperview && firstViewSuperview) {
156 | if (secondViewSuperview == firstViewSuperview) {
157 | closestCommonSuperview = secondViewSuperview;
158 | }
159 | firstViewSuperview = firstViewSuperview.superview;
160 | }
161 | secondViewSuperview = secondViewSuperview.superview;
162 | }
163 | return closestCommonSuperview;
164 | }
165 |
166 | @end
167 |
--------------------------------------------------------------------------------
/CCTimePickerDemo/CCTimePicker/vendor/Masonry/NSLayoutConstraint+MASDebugAdditions.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSLayoutConstraint+MASDebugAdditions.m
3 | // Masonry
4 | //
5 | // Created by Jonas Budelmann on 3/08/13.
6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved.
7 | //
8 |
9 | #import "NSLayoutConstraint+MASDebugAdditions.h"
10 | #import "MASConstraint.h"
11 | #import "MASLayoutConstraint.h"
12 |
13 | @implementation NSLayoutConstraint (MASDebugAdditions)
14 |
15 | #pragma mark - description maps
16 |
17 | + (NSDictionary *)layoutRelationDescriptionsByValue {
18 | static dispatch_once_t once;
19 | static NSDictionary *descriptionMap;
20 | dispatch_once(&once, ^{
21 | descriptionMap = @{
22 | @(NSLayoutRelationEqual) : @"==",
23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=",
24 | @(NSLayoutRelationLessThanOrEqual) : @"<=",
25 | };
26 | });
27 | return descriptionMap;
28 | }
29 |
30 | + (NSDictionary *)layoutAttributeDescriptionsByValue {
31 | static dispatch_once_t once;
32 | static NSDictionary *descriptionMap;
33 | dispatch_once(&once, ^{
34 | descriptionMap = @{
35 | @(NSLayoutAttributeTop) : @"top",
36 | @(NSLayoutAttributeLeft) : @"left",
37 | @(NSLayoutAttributeBottom) : @"bottom",
38 | @(NSLayoutAttributeRight) : @"right",
39 | @(NSLayoutAttributeLeading) : @"leading",
40 | @(NSLayoutAttributeTrailing) : @"trailing",
41 | @(NSLayoutAttributeWidth) : @"width",
42 | @(NSLayoutAttributeHeight) : @"height",
43 | @(NSLayoutAttributeCenterX) : @"centerX",
44 | @(NSLayoutAttributeCenterY) : @"centerY",
45 | @(NSLayoutAttributeBaseline) : @"baseline",
46 |
47 | #if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
48 | @(NSLayoutAttributeFirstBaseline) : @"firstBaseline",
49 | @(NSLayoutAttributeLastBaseline) : @"lastBaseline",
50 | #endif
51 |
52 | #if TARGET_OS_IPHONE || TARGET_OS_TV
53 | @(NSLayoutAttributeLeftMargin) : @"leftMargin",
54 | @(NSLayoutAttributeRightMargin) : @"rightMargin",
55 | @(NSLayoutAttributeTopMargin) : @"topMargin",
56 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin",
57 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin",
58 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin",
59 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins",
60 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins",
61 | #endif
62 |
63 | };
64 |
65 | });
66 | return descriptionMap;
67 | }
68 |
69 |
70 | + (NSDictionary *)layoutPriorityDescriptionsByValue {
71 | static dispatch_once_t once;
72 | static NSDictionary *descriptionMap;
73 | dispatch_once(&once, ^{
74 | #if TARGET_OS_IPHONE || TARGET_OS_TV
75 | descriptionMap = @{
76 | @(MASLayoutPriorityDefaultHigh) : @"high",
77 | @(MASLayoutPriorityDefaultLow) : @"low",
78 | @(MASLayoutPriorityDefaultMedium) : @"medium",
79 | @(MASLayoutPriorityRequired) : @"required",
80 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size",
81 | };
82 | #elif TARGET_OS_MAC
83 | descriptionMap = @{
84 | @(MASLayoutPriorityDefaultHigh) : @"high",
85 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window",
86 | @(MASLayoutPriorityDefaultMedium) : @"medium",
87 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put",
88 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window",
89 | @(MASLayoutPriorityDefaultLow) : @"low",
90 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size",
91 | @(MASLayoutPriorityRequired) : @"required",
92 | };
93 | #endif
94 | });
95 | return descriptionMap;
96 | }
97 |
98 | #pragma mark - description override
99 |
100 | + (NSString *)descriptionForObject:(id)obj {
101 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) {
102 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]];
103 | }
104 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj];
105 | }
106 |
107 | - (NSString *)description {
108 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"];
109 |
110 | [description appendString:[self.class descriptionForObject:self]];
111 |
112 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]];
113 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) {
114 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]];
115 | }
116 |
117 | [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]];
118 |
119 | if (self.secondItem) {
120 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]];
121 | }
122 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) {
123 | [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]];
124 | }
125 |
126 | if (self.multiplier != 1) {
127 | [description appendFormat:@" * %g", self.multiplier];
128 | }
129 |
130 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) {
131 | [description appendFormat:@" %g", self.constant];
132 | } else {
133 | if (self.constant) {
134 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)];
135 | }
136 | }
137 |
138 | if (self.priority != MASLayoutPriorityRequired) {
139 | [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
140 | }
141 |
142 | [description appendString:@">"];
143 | return description;
144 | }
145 |
146 | @end
147 |
--------------------------------------------------------------------------------
/CCTimePicker/vendor/JTCalendar/JTCalendar.m:
--------------------------------------------------------------------------------
1 | //
2 | // JTCalendar.m
3 | // JTCalendar
4 | //
5 | // Created by Jonathan Tribouharet
6 | //
7 |
8 | #import "JTCalendar.h"
9 |
10 | #define NUMBER_PAGES_LOADED 5 // Must be the same in JTCalendarView, JTCalendarMenuView, JTCalendarContentView
11 |
12 | @interface JTCalendar(){
13 | JTCalendarAppearance *calendarAppearance;
14 | BOOL cacheLastWeekMode;
15 | }
16 |
17 | @end
18 |
19 | @implementation JTCalendar
20 |
21 | - (instancetype)init
22 | {
23 | self = [super init];
24 | if(!self){
25 | return nil;
26 | }
27 |
28 | self->_currentDate = [NSDate date];
29 | calendarAppearance = [JTCalendarAppearance new];
30 |
31 | return self;
32 | }
33 |
34 | - (void)setMenuMonthsView:(JTCalendarMenuView *)menuMonthsView
35 | {
36 | [self->_menuMonthsView setDelegate:nil];
37 | [self->_menuMonthsView setCalendarManager:nil];
38 |
39 | self->_menuMonthsView = menuMonthsView;
40 | [self->_menuMonthsView setDelegate:self];
41 | [self->_menuMonthsView setCalendarManager:self];
42 |
43 | cacheLastWeekMode = self.calendarAppearance.isWeekMode;
44 |
45 | [self.menuMonthsView setCurrentDate:self.currentDate];
46 | [self.menuMonthsView reloadAppearance];
47 | }
48 |
49 | - (void)setContentView:(JTCalendarContentView *)contentView
50 | {
51 | [self->_contentView setDelegate:nil];
52 | [self->_contentView setCalendarManager:nil];
53 |
54 | self->_contentView = contentView;
55 | [self->_contentView setDelegate:self];
56 | [self->_contentView setCalendarManager:self];
57 |
58 | [self.contentView setCurrentDate:self.currentDate];
59 | [self.contentView reloadAppearance];
60 | }
61 |
62 | - (void)reloadData
63 | {
64 | // Position to the middle page
65 | CGFloat pageWidth = CGRectGetWidth(self.contentView.frame);
66 | self.contentView.contentOffset = CGPointMake(pageWidth * ((NUMBER_PAGES_LOADED / 2)), self.contentView.contentOffset.y);
67 |
68 | CGFloat menuPageWidth = CGRectGetWidth([self.menuMonthsView.subviews.firstObject frame]);
69 | self.menuMonthsView.contentOffset = CGPointMake(menuPageWidth * ((NUMBER_PAGES_LOADED / 2)), self.menuMonthsView.contentOffset.y);
70 |
71 | [self.contentView reloadData];
72 | }
73 |
74 | - (void)reloadAppearance
75 | {
76 | [self.menuMonthsView reloadAppearance];
77 | [self.contentView reloadAppearance];
78 |
79 | if(cacheLastWeekMode != self.calendarAppearance.isWeekMode){
80 | cacheLastWeekMode = self.calendarAppearance.isWeekMode;
81 | [self setCurrentDate:self.currentDate]; // Reload all data
82 | }
83 | }
84 |
85 | - (void)setCurrentDate:(NSDate *)currentDate
86 | {
87 | self->_currentDate = currentDate;
88 |
89 | [self.menuMonthsView setCurrentDate:currentDate];
90 | [self.contentView setCurrentDate:currentDate];
91 |
92 | [self reloadData]; // For be on the good page and update all DayView
93 | }
94 |
95 | - (JTCalendarAppearance *)calendarAppearance
96 | {
97 | return calendarAppearance;
98 | }
99 |
100 | #pragma mark - UIScrollView delegate
101 |
102 | - (void)scrollViewDidScroll:(UIScrollView *)sender
103 | {
104 | if(self.calendarAppearance.isWeekMode){
105 | return;
106 | }
107 |
108 | if(sender == self.menuMonthsView && self.menuMonthsView.scrollEnabled){
109 | self.contentView.contentOffset = CGPointMake(sender.contentOffset.x * calendarAppearance.ratioContentMenu, self.contentView.contentOffset.y);
110 | }
111 | else if(sender == self.contentView && self.contentView.scrollEnabled){
112 | self.menuMonthsView.contentOffset = CGPointMake(sender.contentOffset.x / calendarAppearance.ratioContentMenu, self.menuMonthsView.contentOffset.y);
113 | }
114 | }
115 |
116 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
117 | {
118 | if(scrollView == self.contentView){
119 | self.menuMonthsView.scrollEnabled = NO;
120 | }
121 | else if(scrollView == self.menuMonthsView){
122 | self.contentView.scrollEnabled = NO;
123 | }
124 | }
125 |
126 | // Use for scroll with scrollRectToVisible or setContentOffset
127 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
128 | {
129 | [self updatePage];
130 | }
131 |
132 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
133 | {
134 | [self updatePage];
135 | }
136 |
137 | - (void)updatePage
138 | {
139 | CGFloat pageWidth = CGRectGetWidth(self.contentView.frame);
140 | CGFloat fractionalPage = self.contentView.contentOffset.x / pageWidth;
141 |
142 | int currentPage = roundf(fractionalPage);
143 | if (currentPage == (NUMBER_PAGES_LOADED / 2)){
144 | self.menuMonthsView.scrollEnabled = YES;
145 | self.contentView.scrollEnabled = YES;
146 | return;
147 | }
148 |
149 | NSCalendar *calendar = calendarAppearance.calendar;
150 | NSDateComponents *dayComponent = [NSDateComponents new];
151 |
152 | if(!self.calendarAppearance.isWeekMode){
153 | dayComponent.month = currentPage - (NUMBER_PAGES_LOADED / 2);
154 | }
155 | else{
156 | dayComponent.day = 7 * (currentPage - (NUMBER_PAGES_LOADED / 2));
157 | }
158 |
159 | NSDate *currentDate = [calendar dateByAddingComponents:dayComponent toDate:self.currentDate options:0];
160 |
161 | [self setCurrentDate:currentDate];
162 |
163 | self.menuMonthsView.scrollEnabled = YES;
164 | self.contentView.scrollEnabled = YES;
165 | }
166 |
167 | - (void)loadNextMonth
168 | {
169 | if(self.calendarAppearance.isWeekMode){
170 | NSLog(@"JTCalendar loadNextMonth ignored");
171 | return;
172 | }
173 |
174 | self.menuMonthsView.scrollEnabled = NO;
175 |
176 | CGRect frame = self.contentView.frame;
177 | frame.origin.x = frame.size.width * ((NUMBER_PAGES_LOADED / 2) + 1);
178 | frame.origin.y = 0;
179 | [self.contentView scrollRectToVisible:frame animated:YES];
180 | }
181 |
182 | - (void)loadPreviousMonth
183 | {
184 | if(self.calendarAppearance.isWeekMode){
185 | NSLog(@"JTCalendar loadPreviousMonth ignored");
186 | return;
187 | }
188 |
189 | self.menuMonthsView.scrollEnabled = NO;
190 |
191 | CGRect frame = self.contentView.frame;
192 | frame.origin.x = frame.size.width * ((NUMBER_PAGES_LOADED / 2) - 1);
193 | frame.origin.y = 0;
194 | [self.contentView scrollRectToVisible:frame animated:YES];
195 | }
196 |
197 | @end
198 |
199 | // 版权属于原作者
200 | // http://code4app.com (cn) http://code4app.net (en)
201 | // 发布代码于最专业的源码分享网站: Code4App.com
202 |
--------------------------------------------------------------------------------