Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions Examples/Calendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
1D2391395A8710F3E85A74 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A73 /* QuartzCore.framework */; };
1D2391395A8710F3E85A76 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A75 /* CoreGraphics.framework */; };
1D2391395A8710F3E85A85 /* CKCalendarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A84 /* CKCalendarView.m */; };
1D2391395A8710F3E85A88 /* left_arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A87 /* left_arrow.png */; };
1D2391395A8710F3E85A8A /* left_arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A89 /* left_arrow@2x.png */; };
1D2391395A8710F3E85A8C /* right_arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A8B /* right_arrow.png */; };
1D2391395A8710F3E85A8E /* right_arrow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1D2391395A8710F3E85A8D /* right_arrow@2x.png */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -38,10 +34,6 @@
1D2391395A8710F3E85A75 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
1D2391395A8710F3E85A83 /* CKCalendarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CKCalendarView.h; path = ../../Source/CKCalendarView.h; sourceTree = "<group>"; };
1D2391395A8710F3E85A84 /* CKCalendarView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CKCalendarView.m; path = ../../Source/CKCalendarView.m; sourceTree = "<group>"; };
1D2391395A8710F3E85A87 /* left_arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = left_arrow.png; path = ../../Source/resources/left_arrow.png; sourceTree = "<group>"; };
1D2391395A8710F3E85A89 /* left_arrow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "left_arrow@2x.png"; path = "../../Source/resources/left_arrow@2x.png"; sourceTree = "<group>"; };
1D2391395A8710F3E85A8B /* right_arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = right_arrow.png; path = ../../Source/resources/right_arrow.png; sourceTree = "<group>"; };
1D2391395A8710F3E85A8D /* right_arrow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "right_arrow@2x.png"; path = "../../Source/resources/right_arrow@2x.png"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -90,10 +82,10 @@
1D2391395A8710F3E85A5A /* Calendar */ = {
isa = PBXGroup;
children = (
1D2391395A8710F3E85A84 /* CKCalendarView.m */,
1D2391395A8710F3E85A83 /* CKCalendarView.h */,
1D2391395A8710F3E85A67 /* CKViewController.m */,
1D2391395A8710F3E85A84 /* CKCalendarView.m */,
1D2391395A8710F3E85A66 /* CKViewController.h */,
1D2391395A8710F3E85A67 /* CKViewController.m */,
1D2391395A8710F3E85A64 /* CKAppDelegate.m */,
1D2391395A8710F3E85A63 /* CKAppDelegate.h */,
1D2391395A8710F3E85A5B /* Supporting Files */,
Expand All @@ -116,10 +108,6 @@
1D2391395A8710F3E85A86 /* resources */ = {
isa = PBXGroup;
children = (
1D2391395A8710F3E85A8D /* right_arrow@2x.png */,
1D2391395A8710F3E85A8B /* right_arrow.png */,
1D2391395A8710F3E85A89 /* left_arrow@2x.png */,
1D2391395A8710F3E85A87 /* left_arrow.png */,
);
name = resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -149,6 +137,9 @@
/* Begin PBXProject section */
001D2391395A8710F3E85A45 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
};
buildConfigurationList = 1D2391395A8710F3E85A46 /* Build configuration list for PBXProject "Calendar" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
Expand All @@ -172,10 +163,6 @@
buildActionMask = 2147483647;
files = (
1D2391395A8710F3E85A5F /* InfoPlist.strings in Resources */,
1D2391395A8710F3E85A88 /* left_arrow.png in Resources */,
1D2391395A8710F3E85A8A /* left_arrow@2x.png in Resources */,
1D2391395A8710F3E85A8C /* right_arrow.png in Resources */,
1D2391395A8710F3E85A8E /* right_arrow@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -213,6 +200,10 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -234,6 +225,10 @@
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand Down Expand Up @@ -295,6 +290,7 @@
1D2391395A8710F3E85A4F /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
31 changes: 23 additions & 8 deletions Examples/Calendar/CKViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ @interface CKViewController () <CKCalendarDelegate>
@property(nonatomic, strong) NSDateFormatter *dateFormatter;
@property(nonatomic, strong) NSDate *minimumDate;
@property(nonatomic, strong) NSArray *disabledDates;
@property(nonatomic, strong) NSArray *birthDays;

@end

Expand All @@ -17,7 +18,7 @@ @implementation CKViewController
- (id)init {
self = [super init];
if (self) {
CKCalendarView *calendar = [[CKCalendarView alloc] initWithStartDay:startMonday];
CKCalendarView *calendar = [[CKCalendarView alloc] initWithStartDay:SATURDAY];
self.calendar = calendar;
calendar.delegate = self;

Expand All @@ -30,11 +31,23 @@ - (id)init {
[self.dateFormatter dateFromString:@"06/01/2013"],
[self.dateFormatter dateFromString:@"07/01/2013"]
];

self.birthDays = @[
[self.dateFormatter dateFromString:@"07/01/2013"],
[self.dateFormatter dateFromString:@"11/01/2013"],
[self.dateFormatter dateFromString:@"05/02/2013"],
[self.dateFormatter dateFromString:@"25/01/2013"]
];

self.calendar.offDays = @[
[NSNumber numberWithInt:FRIDAY],
[NSNumber numberWithInt:SATURDAY]
];

calendar.onlyShowCurrentMonth = NO;
calendar.adaptHeightToNumberOfWeeksInMonth = YES;

calendar.frame = CGRectMake(10, 10, 300, 320);
calendar.frame = CGRectMake(10, 50, 300, 320);
[self.view addSubview:calendar];

self.dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(calendar.frame) + 4, self.view.bounds.size.width, 24)];
Expand Down Expand Up @@ -77,12 +90,7 @@ - (void)localeDidChange {
}

- (BOOL)dateIsDisabled:(NSDate *)date {
for (NSDate *disabledDate in self.disabledDates) {
if ([disabledDate isEqualToDate:date]) {
return YES;
}
}
return NO;
return [self.disabledDates containsObject:date];
}

#pragma mark -
Expand All @@ -93,6 +101,13 @@ - (void)calendar:(CKCalendarView *)calendar configureDateItem:(CKDateItem *)date
if ([self dateIsDisabled:date]) {
dateItem.backgroundColor = [UIColor redColor];
dateItem.textColor = [UIColor whiteColor];
dateItem.offDayTextColor = [UIColor whiteColor];
}
if ([self.birthDays containsObject:date]) {
if([self dateIsDisabled:date])
dateItem.notificationColor = [UIColor cyanColor];
else
dateItem.notificationColor = [UIColor purpleColor];
}
}

Expand Down
21 changes: 15 additions & 6 deletions Source/CKCalendarView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,31 @@
@property (nonatomic, strong) UIColor *selectedBackgroundColor;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, strong) UIColor *selectedTextColor;
@property (nonatomic, strong) UIColor *offDayTextColor;
@property (nonatomic, strong) UIColor *notificationColor; // default: nil for no notification

@end

typedef enum {
startSunday = 1,
startMonday = 2,
} CKCalendarStartDay;
SUNDAY = 1,
MONDAY = 2,
TUESDAY = 3,
WEDNESDAY = 4,
THURSDAY = 5,
FRIDAY = 6,
SATURDAY = 7
} CKCalendarWeekDay;

@interface CKCalendarView : UIView

- (id)initWithStartDay:(CKCalendarStartDay)firstDay;
- (id)initWithStartDay:(CKCalendarStartDay)firstDay frame:(CGRect)frame;
- (id)initWithStartDay:(CKCalendarWeekDay)firstDay;
- (id)initWithStartDay:(CKCalendarWeekDay)firstDay frame:(CGRect)frame;

@property (nonatomic) CKCalendarStartDay calendarStartDay;
@property (nonatomic) CKCalendarWeekDay calendarStartDay;
@property (nonatomic, strong) NSLocale *locale;
@property (nonatomic) BOOL onlyShowCurrentMonth;
@property (nonatomic) BOOL adaptHeightToNumberOfWeeksInMonth;
@property (nonatomic, strong) NSArray *offDays;

@property (nonatomic, weak) id<CKCalendarDelegate> delegate;

Expand All @@ -49,6 +57,7 @@ typedef enum {
@property (nonatomic, strong) UIFont *dateOfWeekFont;
@property (nonatomic, strong) UIColor *dayOfWeekTextColor;
@property (nonatomic, strong) UIFont *dateFont;
@property (nonatomic) CGSize monthButtonSize;

- (void)setMonthButtonColor:(UIColor *)color;
- (void)setInnerBorderColor:(UIColor *)color;
Expand Down
Loading