From b95fdf89751c998445d57db31ec5e846d7b618b4 Mon Sep 17 00:00:00 2001 From: Robert Dimitrov Date: Fri, 1 Nov 2013 18:22:00 +0200 Subject: [PATCH] Add additional functionality to RDVCalendarDayCell, remove RDVCalendarHeaderView. --- Example/Classes/RDVAppDelegate.h | 23 ++++- Example/Classes/RDVAppDelegate.m | 31 ++++-- Example/Classes/RDVExampleViewController.h | 13 +++ Example/Classes/RDVExampleViewController.m | 47 +++++++++ Example/main.m | 23 ++++- RDVCalendarView.xcodeproj/project.pbxproj | 16 +-- RDVCalendarView/RDVCalendarDayCell.h | 81 ++++++++++++--- RDVCalendarView/RDVCalendarDayCell.m | 104 +++++++++++++++----- RDVCalendarView/RDVCalendarHeaderView.h | 17 ---- RDVCalendarView/RDVCalendarHeaderView.m | 55 ----------- RDVCalendarView/RDVCalendarMonthView.h | 23 ++++- RDVCalendarView/RDVCalendarMonthView.m | 23 ++++- RDVCalendarView/RDVCalendarView.h | 49 +++++++-- RDVCalendarView/RDVCalendarView.m | 83 +++++++++++----- RDVCalendarView/RDVCalendarViewController.h | 25 ++++- RDVCalendarView/RDVCalendarViewController.m | 34 ++++--- RDVCalendarView/RDVCalendarWeekDaysHeader.h | 23 ++++- RDVCalendarView/RDVCalendarWeekDaysHeader.m | 23 ++++- 18 files changed, 497 insertions(+), 196 deletions(-) create mode 100644 Example/Classes/RDVExampleViewController.h create mode 100644 Example/Classes/RDVExampleViewController.m delete mode 100644 RDVCalendarView/RDVCalendarHeaderView.h delete mode 100644 RDVCalendarView/RDVCalendarHeaderView.m diff --git a/Example/Classes/RDVAppDelegate.h b/Example/Classes/RDVAppDelegate.h index 022962c..54894bf 100644 --- a/Example/Classes/RDVAppDelegate.h +++ b/Example/Classes/RDVAppDelegate.h @@ -1,10 +1,25 @@ +// RDVAppDelegate.h +// RDVCalendarView // -// RDVAppDelegate.h -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import diff --git a/Example/Classes/RDVAppDelegate.m b/Example/Classes/RDVAppDelegate.m index 47bdf0d..da87d43 100644 --- a/Example/Classes/RDVAppDelegate.m +++ b/Example/Classes/RDVAppDelegate.m @@ -1,13 +1,28 @@ +// RDVAppDelegate.m +// RDVCalendarView // -// RDVAppDelegate.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "RDVAppDelegate.h" -#import "RDVCalendarViewController.h" +#import "RDVExampleViewController.h" @implementation RDVAppDelegate @@ -16,10 +31,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; - UIViewController *calendarViewController = [[RDVCalendarViewController alloc] init]; - [self.window setRootViewController:calendarViewController]; + UIViewController *calendarViewController = [[RDVExampleViewController alloc] init]; + UIViewController *navigationController = [[UINavigationController alloc] initWithRootViewController:calendarViewController]; + [self.window setRootViewController:navigationController]; [self.window makeKeyAndVisible]; + return YES; } diff --git a/Example/Classes/RDVExampleViewController.h b/Example/Classes/RDVExampleViewController.h new file mode 100644 index 0000000..acf3915 --- /dev/null +++ b/Example/Classes/RDVExampleViewController.h @@ -0,0 +1,13 @@ +// +// RDVExampleViewController.h +// RDVCalendarView +// +// Created by Robert Dimitrov on 11/1/13. +// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// + +#import "RDVCalendarViewController.h" + +@interface RDVExampleViewController : RDVCalendarViewController + +@end diff --git a/Example/Classes/RDVExampleViewController.m b/Example/Classes/RDVExampleViewController.m new file mode 100644 index 0000000..3ef7328 --- /dev/null +++ b/Example/Classes/RDVExampleViewController.m @@ -0,0 +1,47 @@ +// RDVExampleViewController.m +// RDVCalendarView +// +// Copyright (c) 2013 Robert Dimitrov +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "RDVExampleViewController.h" + +@interface RDVExampleViewController () + +@end + +@implementation RDVExampleViewController + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + self.title = @"Calendar"; + } + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + [[self.navigationController navigationBar] setTranslucent:NO]; +} + +@end diff --git a/Example/main.m b/Example/main.m index c52eb6d..b34821c 100644 --- a/Example/main.m +++ b/Example/main.m @@ -1,10 +1,25 @@ +// main.m +// RDVCalendarView // -// main.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import diff --git a/RDVCalendarView.xcodeproj/project.pbxproj b/RDVCalendarView.xcodeproj/project.pbxproj index f42a3d7..beb976f 100644 --- a/RDVCalendarView.xcodeproj/project.pbxproj +++ b/RDVCalendarView.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 62C2389217CB463C009B4090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 62C2388817CB463C009B4090 /* InfoPlist.strings */; }; 62C2389317CB463C009B4090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C2388A17CB463C009B4090 /* main.m */; }; 62C2389A17CB472B009B4090 /* RDVAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C2389917CB472B009B4090 /* RDVAppDelegate.m */; }; - 62C2389D17CB4765009B4090 /* RDVCalendarHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C2389C17CB4765009B4090 /* RDVCalendarHeaderView.m */; }; 62C238A117CB4E97009B4090 /* RDVCalendarWeekDaysHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C238A017CB4E97009B4090 /* RDVCalendarWeekDaysHeader.m */; }; 62C238A417CB6814009B4090 /* RDVCalendarMonthView.m in Sources */ = {isa = PBXBuildFile; fileRef = 62C238A317CB6814009B4090 /* RDVCalendarMonthView.m */; }; 62F77D3617BE0080009873CE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 62F77D3517BE0080009873CE /* UIKit.framework */; }; @@ -24,6 +23,7 @@ 62F77D5A17BE0105009873CE /* RDVCalendarDayCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 62F77D5917BE0105009873CE /* RDVCalendarDayCell.m */; }; B44421A817BE61A300A048A6 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = B44421A617BE61A300A048A6 /* LICENSE */; }; B44421A917BE61A300A048A6 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = B44421A717BE61A300A048A6 /* README.md */; }; + B46DECE11823FE5400D4A823 /* RDVExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B46DECE01823FE5400D4A823 /* RDVExampleViewController.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -36,8 +36,6 @@ 62C2388E17CB463C009B4090 /* RDVCalendarView-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RDVCalendarView-Prefix.pch"; sourceTree = ""; }; 62C2389817CB472B009B4090 /* RDVAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RDVAppDelegate.h; sourceTree = ""; }; 62C2389917CB472B009B4090 /* RDVAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RDVAppDelegate.m; sourceTree = ""; }; - 62C2389B17CB4765009B4090 /* RDVCalendarHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RDVCalendarHeaderView.h; sourceTree = ""; }; - 62C2389C17CB4765009B4090 /* RDVCalendarHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RDVCalendarHeaderView.m; sourceTree = ""; }; 62C2389F17CB4E97009B4090 /* RDVCalendarWeekDaysHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RDVCalendarWeekDaysHeader.h; sourceTree = ""; }; 62C238A017CB4E97009B4090 /* RDVCalendarWeekDaysHeader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RDVCalendarWeekDaysHeader.m; sourceTree = ""; }; 62C238A217CB6813009B4090 /* RDVCalendarMonthView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RDVCalendarMonthView.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -54,6 +52,8 @@ 62F77D5917BE0105009873CE /* RDVCalendarDayCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RDVCalendarDayCell.m; sourceTree = ""; }; B44421A617BE61A300A048A6 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; B44421A717BE61A300A048A6 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = ""; }; + B46DECDF1823FE5400D4A823 /* RDVExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RDVExampleViewController.h; sourceTree = ""; }; + B46DECE01823FE5400D4A823 /* RDVExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RDVExampleViewController.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -98,6 +98,8 @@ children = ( 62C2389817CB472B009B4090 /* RDVAppDelegate.h */, 62C2389917CB472B009B4090 /* RDVAppDelegate.m */, + B46DECDF1823FE5400D4A823 /* RDVExampleViewController.h */, + B46DECE01823FE5400D4A823 /* RDVExampleViewController.m */, ); path = Classes; sourceTree = ""; @@ -141,8 +143,6 @@ 62F77D5617BE00BB009873CE /* RDVCalendarView.m */, 62F77D5817BE0105009873CE /* RDVCalendarDayCell.h */, 62F77D5917BE0105009873CE /* RDVCalendarDayCell.m */, - 62C2389B17CB4765009B4090 /* RDVCalendarHeaderView.h */, - 62C2389C17CB4765009B4090 /* RDVCalendarHeaderView.m */, 62C2389F17CB4E97009B4090 /* RDVCalendarWeekDaysHeader.h */, 62C238A017CB4E97009B4090 /* RDVCalendarWeekDaysHeader.m */, 62C238A217CB6813009B4090 /* RDVCalendarMonthView.h */, @@ -224,7 +224,7 @@ 62F77D5A17BE0105009873CE /* RDVCalendarDayCell.m in Sources */, 62C2389317CB463C009B4090 /* main.m in Sources */, 62C2389A17CB472B009B4090 /* RDVAppDelegate.m in Sources */, - 62C2389D17CB4765009B4090 /* RDVCalendarHeaderView.m in Sources */, + B46DECE11823FE5400D4A823 /* RDVExampleViewController.m in Sources */, 62C238A117CB4E97009B4090 /* RDVCalendarWeekDaysHeader.m in Sources */, 62C238A417CB6814009B4090 /* RDVCalendarMonthView.m in Sources */, ); @@ -310,7 +310,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Example/RDVCalendarView-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; name = Debug; @@ -323,7 +323,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Example/RDVCalendarView-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.0; PRODUCT_NAME = "$(TARGET_NAME)"; - TARGETED_DEVICE_FAMILY = 1; + TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; name = Release; diff --git a/RDVCalendarView/RDVCalendarDayCell.h b/RDVCalendarView/RDVCalendarDayCell.h index 2ea0de1..d1f423e 100644 --- a/RDVCalendarView/RDVCalendarDayCell.h +++ b/RDVCalendarView/RDVCalendarDayCell.h @@ -1,34 +1,93 @@ +// RDVCalendarDayCell.h +// RDVCalendarView // -// RDVCalendarDayCell.h -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import typedef NS_ENUM(NSInteger, RDVCalendarDayCellSelectionStyle) { RDVCalendarDayCellSelectionStyleNone, - RDVCalendarDayCellSelectionStyleNormal, + RDVCalendarDayCellSelectionStyleDefault, }; @interface RDVCalendarDayCell : UIView +/** + * A string used to identify a day cell that is reusable. (read-only) + */ @property(nonatomic, readonly, copy) NSString *reuseIdentifier; -@property (nonatomic, readonly) UILabel *titleLabel; -@property (nonatomic) UIView *contentView; -@property (nonatomic) UIView *backgroundView; -@property (nonatomic) UIView *selectedBackgroundView; +/** + * Returns the label used for the main textual content of the day cell. (read-only) + */ +@property (nonatomic, readonly) UILabel *textLabel; + +/** + * Returns the content view of the day cell object. (read-only) + */ +@property (nonatomic, readonly) UIView *contentView; + +/** + * The view used as the background of the day cell. + */ +@property (nonatomic, strong) UIView *backgroundView; + +/** + * The view used as the background of the day cell when it is selected. + */ +@property (nonatomic, strong) UIView *selectedBackgroundView; +/** + * The style of selection for a cell. + */ +@property(nonatomic) RDVCalendarDayCellSelectionStyle selectionStyle; +/** + * A Boolean value that indicates whether the cell is selected. + */ @property(nonatomic, getter = isSelected) BOOL selected; -- (id)initWithStyle:(RDVCalendarDayCellSelectionStyle)style reuseIdentifier:(NSString *)reuseIdentifier; +/** + * A Boolean value that indicates whether the cell is highlighted. + */ +@property(nonatomic, getter = isHighlighted) BOOL highlighted; + +/** + * Initializes a day cell with a reuse identifier and returns it to the caller. + */ +- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier; + +/** + * Sets the selected state of the cell, optionally animating the transition between states. + */ - (void)setSelected:(BOOL)selected animated:(BOOL)animated; -- (void)setSelected:(BOOL)selected; +/** + * Sets the highlighted state of the cell, optionally animating the transition between states. + */ +- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated; + +/** + * Prepares a reusable day cell for reuse by the calendar view. + */ - (void)prepareForReuse; @end diff --git a/RDVCalendarView/RDVCalendarDayCell.m b/RDVCalendarView/RDVCalendarDayCell.m index 7450946..0e8e4ec 100644 --- a/RDVCalendarView/RDVCalendarDayCell.m +++ b/RDVCalendarView/RDVCalendarDayCell.m @@ -1,24 +1,43 @@ +// RDVCalendarDayCell.m +// RDVCalendarView // -// RDVCalendarDayCell.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "RDVCalendarDayCell.h" @interface RDVCalendarDayCell() { BOOL _selected; + BOOL _highlighted; } @end @implementation RDVCalendarDayCell -- (id)initWithStyle:(RDVCalendarDayCellSelectionStyle)style reuseIdentifier:(NSString *)reuseIdentifier { +- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier { self = [super init]; if (self) { + _reuseIdentifier = [reuseIdentifier copy]; + _selectionStyle = RDVCalendarDayCellSelectionStyleDefault; + _backgroundView = [[UIView alloc] init]; [_backgroundView setBackgroundColor:[UIColor whiteColor]]; [self addSubview:_backgroundView]; @@ -32,32 +51,34 @@ - (id)initWithStyle:(RDVCalendarDayCellSelectionStyle)style reuseIdentifier:(NSS [_contentView setBackgroundColor:[UIColor clearColor]]; [self addSubview:_contentView]; - _titleLabel = [[UILabel alloc] init]; - [_titleLabel setTextColor:[UIColor blackColor]]; - [_titleLabel setBackgroundColor:[UIColor clearColor]]; - [_titleLabel setFont:[UIFont systemFontOfSize:20]]; - [_contentView addSubview:_titleLabel]; + _textLabel = [[UILabel alloc] init]; + [_textLabel setTextColor:[UIColor blackColor]]; + [_textLabel setBackgroundColor:[UIColor clearColor]]; + [_textLabel setFont:[UIFont systemFontOfSize:20]]; + [_contentView addSubview:_textLabel]; } return self; } - (id)init { - return [self initWithStyle:RDVCalendarDayCellSelectionStyleNormal reuseIdentifier:nil]; + return [self initWithReuseIdentifier:@""]; } - (void)layoutSubviews { CGSize frameSize = self.frame.size; - CGSize titleSize = [[self titleLabel] sizeThatFits:CGSizeMake(frameSize.width, frameSize.height)]; + CGSize titleSize = [[self textLabel] sizeThatFits:CGSizeMake(frameSize.width, frameSize.height)]; [[self backgroundView] setFrame:self.bounds]; [[self selectedBackgroundView] setFrame:self.bounds]; [[self contentView] setFrame:self.bounds]; - [[self titleLabel] setFrame:CGRectMake(roundf(frameSize.width / 2 - titleSize.width / 2), + [[self textLabel] setFrame:CGRectMake(roundf(frameSize.width / 2 - titleSize.width / 2), roundf(frameSize.height / 2 - titleSize.height / 2), titleSize.width, titleSize.height)]; } +#pragma mark - Selection + - (BOOL)isSelected { return _selected; } @@ -71,32 +92,71 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated { void (^block)() = ^{ if (selected) { - [[self backgroundView] setAlpha:0]; - [[self selectedBackgroundView] setAlpha:1]; + [[self backgroundView] setAlpha:0.0f]; + [[self selectedBackgroundView] setAlpha:1.0f]; } else { - [[self backgroundView] setAlpha:1]; - [[self selectedBackgroundView] setAlpha:0]; + [[self backgroundView] setAlpha:1.0f]; + [[self selectedBackgroundView] setAlpha:0.0f]; } - [[self titleLabel] setHighlighted:selected]; + [[self textLabel] setHighlighted:selected]; }; if (animated) { - [UIView animateWithDuration:0.25 animations:block]; + [UIView animateWithDuration:0.25f animations:block]; } else { block(); } } - (void)setSelected:(BOOL)selected { - [self setSelected:selected animated:YES]; + [self setSelected:selected animated:NO]; } +- (BOOL)isHighlighted { + return _highlighted; +} + +- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { + if (highlighted == _highlighted) { + return; + } + + _highlighted = highlighted; + + void (^block)() = ^{ + if (highlighted) { + [[self backgroundView] setAlpha:0.0f]; + [[self selectedBackgroundView] setAlpha:1.0f]; + } else { + [[self backgroundView] setAlpha:1.0f]; + [[self selectedBackgroundView] setAlpha:0.0f]; + } + [[self textLabel] setHighlighted:highlighted]; + }; + + if (animated) { + [UIView animateWithDuration:0.25f animations:block]; + } else { + block(); + } +} + +- (void)setHighlighted:(BOOL)highlighted { + [self setHighlighted:highlighted animated:NO]; +} + +#pragma mark - Cell reuse + - (void)prepareForReuse { if ([self isSelected]) { - [self setSelected:NO animated:NO]; + [self setSelected:NO]; + } + + if ([self isHighlighted]) { + [self setHighlighted:NO]; } - [[self titleLabel] setText:@""]; + [[self textLabel] setText:@""]; } @end diff --git a/RDVCalendarView/RDVCalendarHeaderView.h b/RDVCalendarView/RDVCalendarHeaderView.h deleted file mode 100644 index 23706f4..0000000 --- a/RDVCalendarView/RDVCalendarHeaderView.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// RDVCalendarHeaderView.h -// RDVCalendarView -// -// Created by Robert Dimitrov on 8/26/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. -// - -#import - -@interface RDVCalendarHeaderView : UIView - -@property (nonatomic) UILabel *titleLabel; -@property (nonatomic) UIButton *backButton; -@property (nonatomic) UIButton *forwardButton; - -@end diff --git a/RDVCalendarView/RDVCalendarHeaderView.m b/RDVCalendarView/RDVCalendarHeaderView.m deleted file mode 100644 index b9cdc55..0000000 --- a/RDVCalendarView/RDVCalendarHeaderView.m +++ /dev/null @@ -1,55 +0,0 @@ -// -// RDVCalendarHeaderView.m -// RDVCalendarView -// -// Created by Robert Dimitrov on 8/26/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. -// - -#import "RDVCalendarHeaderView.h" - -@implementation RDVCalendarHeaderView - -- (id)initWithFrame:(CGRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - _titleLabel = [[UILabel alloc] init]; - [_titleLabel setFont:[UIFont systemFontOfSize:22]]; - [_titleLabel setTextColor:[UIColor blackColor]]; - [self addSubview:_titleLabel]; - - _backButton = [[UIButton alloc] init]; - [_backButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; - [_backButton setTitle:@"Prev" forState:UIControlStateNormal]; - [self addSubview:_backButton]; - - _forwardButton = [[UIButton alloc] init]; - [_forwardButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; - [_forwardButton setTitle:@"Next" forState:UIControlStateNormal]; - [self addSubview:_forwardButton]; - } - return self; -} - -- (void)layoutSubviews { - CGSize viewSize = self.frame.size; - - CGSize previousMonthButtonSize = [[self backButton] sizeThatFits:CGSizeMake(100, 50)]; - CGSize nextMonthButtonSize = [[self forwardButton] sizeThatFits:CGSizeMake(100, 50)]; - CGSize titleSize = [[self titleLabel] sizeThatFits:CGSizeMake(viewSize.width - previousMonthButtonSize.width - - nextMonthButtonSize.width, 50)]; - - [self.backButton setFrame:CGRectMake(10, roundf(viewSize.height / 2 - previousMonthButtonSize.height / 2), - previousMonthButtonSize.width, previousMonthButtonSize.height)]; - - [self.titleLabel setFrame:CGRectMake(roundf(viewSize.width / 2 - titleSize.width / 2), - roundf(viewSize.height / 2 - titleSize.height / 2), - titleSize.width, titleSize.height)]; - - [self.forwardButton setFrame:CGRectMake(viewSize.width - 10 - nextMonthButtonSize.width, - roundf(viewSize.height / 2 - nextMonthButtonSize.height / 2), - nextMonthButtonSize.width, nextMonthButtonSize.height)]; -} - -@end diff --git a/RDVCalendarView/RDVCalendarMonthView.h b/RDVCalendarView/RDVCalendarMonthView.h index 9be2013..9e0a70d 100644 --- a/RDVCalendarView/RDVCalendarMonthView.h +++ b/RDVCalendarView/RDVCalendarMonthView.h @@ -1,10 +1,25 @@ +// RDVCalendarMonthView.h +// RDVCalendarView // -// RDVCalendarMonthView.h -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/26/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import diff --git a/RDVCalendarView/RDVCalendarMonthView.m b/RDVCalendarView/RDVCalendarMonthView.m index bd00342..3ff4a0a 100644 --- a/RDVCalendarView/RDVCalendarMonthView.m +++ b/RDVCalendarView/RDVCalendarMonthView.m @@ -1,10 +1,25 @@ +// RDVCalendarMonthView.m +// RDVCalendarView // -// RDVCalendarMonthView.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/26/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "RDVCalendarMonthView.h" #import "RDVCalendarDayCell.h" diff --git a/RDVCalendarView/RDVCalendarView.h b/RDVCalendarView/RDVCalendarView.h index 5787c17..3a275d6 100644 --- a/RDVCalendarView/RDVCalendarView.h +++ b/RDVCalendarView/RDVCalendarView.h @@ -1,21 +1,56 @@ +// RDVCalendarView.h +// RDVCalendarView // -// RDVCalendarView.h -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import +#import "RDVCalendarMonthView.h" +#import "RDVCalendarDayCell.h" +#import "RDVCalendarWeekDaysHeader.h" @class RDVCalendarHeaderView; @protocol RDVCalendarViewDelegate; -@interface RDVCalendarView : UIView +@interface RDVCalendarView : UIView @property (weak) id delegate; -@property (nonatomic) RDVCalendarHeaderView *headerView; + +/** + * Returns the label, which contains the name of the currently displayed month. (read-only) + */ +@property (nonatomic, readonly) UILabel *monthLabel; + +/** + * Returns the back (previous month) button. (read-only) + */ +@property (nonatomic, readonly) UIButton *backButton; + +/** + * Returns the forward (next month) button. (read-only) + */ +@property (nonatomic, readonly) UIButton *forwardButton; + +@property (nonatomic) RDVCalendarWeekDaysHeader *weekDaysView; +@property (nonatomic) RDVCalendarMonthView *monthView; @property (nonatomic) UIColor *currentDayColor; @property (nonatomic) UIColor *normalDayColor; @@ -32,5 +67,7 @@ @protocol RDVCalendarViewDelegate @optional +- (BOOL)calendarView:(RDVCalendarView *)calendarView shouldSelectDate:(NSDate *)date; +- (void)calendarView:(RDVCalendarView *)calendarView willSelectDate:(NSDate *)date; - (void)calendarView:(RDVCalendarView *)calendarView didSelectDate:(NSDate *)date; @end diff --git a/RDVCalendarView/RDVCalendarView.m b/RDVCalendarView/RDVCalendarView.m index 203951e..a5f977d 100644 --- a/RDVCalendarView/RDVCalendarView.m +++ b/RDVCalendarView/RDVCalendarView.m @@ -1,23 +1,31 @@ +// RDVCalendarView.m +// RDVCalendarView // -// RDVCalendarView.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "RDVCalendarView.h" -#import "RDVCalendarDayCell.h" -#import "RDVCalendarWeekDaysHeader.h" -#import "RDVCalendarHeaderView.h" -#import "RDVCalendarMonthView.h" #import @interface RDVCalendarView () -@property (nonatomic) RDVCalendarWeekDaysHeader *weekDaysView; -@property (nonatomic) RDVCalendarMonthView *monthView; - @property NSDateComponents *selectedDay; @property NSDateComponents *month; @property NSDateComponents *currentDay; @@ -67,14 +75,25 @@ - (id)initWithFrame:(CGRect)frame - (void)layoutSubviews { CGSize viewSize = self.frame.size; + CGSize headerSize = CGSizeMake(viewSize.width, 60.0f); - if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { - viewSize = CGSizeMake(CGRectGetHeight(self.frame), CGRectGetWidth(self.frame)); - } + CGSize previousMonthButtonSize = [[self backButton] sizeThatFits:CGSizeMake(100, 50)]; + CGSize nextMonthButtonSize = [[self forwardButton] sizeThatFits:CGSizeMake(100, 50)]; + CGSize titleSize = [[self monthLabel] sizeThatFits:CGSizeMake(headerSize.width - previousMonthButtonSize.width - + nextMonthButtonSize.width, 50)]; + + [[self backButton] setFrame:CGRectMake(10, roundf(headerSize.height / 2 - previousMonthButtonSize.height / 2), + previousMonthButtonSize.width, previousMonthButtonSize.height)]; - [[self headerView] setFrame:CGRectMake(0, 0, viewSize.width, 60)]; + [[self monthLabel] setFrame:CGRectMake(roundf(headerSize.width / 2 - titleSize.width / 2), + roundf(headerSize.height / 2 - titleSize.height / 2), + titleSize.width, titleSize.height)]; - [[self weekDaysView] setFrame:CGRectMake(0, CGRectGetMaxY([self headerView].frame), viewSize.width, 30)]; + [[self forwardButton] setFrame:CGRectMake(headerSize.width - 10 - nextMonthButtonSize.width, + roundf(headerSize.height / 2 - nextMonthButtonSize.height / 2), + nextMonthButtonSize.width, nextMonthButtonSize.height)]; + + [[self weekDaysView] setFrame:CGRectMake(0, headerSize.height, viewSize.width, 30)]; CGSize monthViewSize = [[self monthView] sizeThatFits:CGSizeMake(viewSize.width, viewSize.height - CGRectGetMaxY([self weekDaysView].frame))]; @@ -82,12 +101,24 @@ - (void)layoutSubviews { } - (void)setupViews { - _headerView = [[RDVCalendarHeaderView alloc] init]; - [[_headerView backButton] addTarget:self action:@selector(previousMonthButtonTapped:) + _monthLabel = [[UILabel alloc] init]; + [_monthLabel setFont:[UIFont systemFontOfSize:22]]; + [_monthLabel setTextColor:[UIColor blackColor]]; + [self addSubview:_monthLabel]; + + _backButton = [[UIButton alloc] init]; + [_backButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; + [_backButton setTitle:@"Prev" forState:UIControlStateNormal]; + [_backButton addTarget:self action:@selector(previousMonthButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [[_headerView forwardButton] addTarget:self action:@selector(nextMonthButtonTapped:) + [self addSubview:_backButton]; + + _forwardButton = [[UIButton alloc] init]; + [_forwardButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; + [_forwardButton setTitle:@"Next" forState:UIControlStateNormal]; + [_forwardButton addTarget:self action:@selector(nextMonthButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; - [self addSubview:_headerView]; + [self addSubview:_forwardButton]; _weekDaysView = [[RDVCalendarWeekDaysHeader alloc] init]; [self addSubview:_weekDaysView]; @@ -122,9 +153,7 @@ - (void)updateMonthLabelMonth:(NSDateComponents*)month { formatter.dateFormat = @"MMMM yyyy"; NSDate *date = [month.calendar dateFromComponents:month]; - self.headerView.titleLabel.text = [formatter stringFromDate:date]; - - [[self headerView] setNeedsLayout]; + self.monthLabel.text = [formatter stringFromDate:date]; } - (void)updateMonthViewMonth:(NSDateComponents *)month { @@ -175,12 +204,12 @@ - (RDVCalendarDayCell *)calendarMonthView:(RDVCalendarMonthView *)calendarMonthV RDVCalendarDayCell *dayCell = [calendarMonthView dequeueReusableCellWithIdentifier:DayIdentifier]; if (!dayCell) { - dayCell = [[RDVCalendarDayCell alloc] initWithStyle:RDVCalendarDayCellSelectionStyleNormal reuseIdentifier:DayIdentifier]; - [[dayCell titleLabel] setTextColor:[self dayTextColor]]; - [[dayCell titleLabel] setHighlightedTextColor:[self highlightedDayTextColor]]; + dayCell = [[RDVCalendarDayCell alloc] initWithReuseIdentifier:DayIdentifier]; + [[dayCell textLabel] setTextColor:[self dayTextColor]]; + [[dayCell textLabel] setHighlightedTextColor:[self highlightedDayTextColor]]; } - [dayCell.titleLabel setText:[NSString stringWithFormat:@"%d", index + 1]]; + [dayCell.textLabel setText:[NSString stringWithFormat:@"%d", index + 1]]; if (index + 1 == [self currentDay].day && [self month].month == [self currentDay].month && diff --git a/RDVCalendarView/RDVCalendarViewController.h b/RDVCalendarView/RDVCalendarViewController.h index cb09ef1..3b38e9e 100644 --- a/RDVCalendarView/RDVCalendarViewController.h +++ b/RDVCalendarView/RDVCalendarViewController.h @@ -1,10 +1,25 @@ +// RDVCalendarViewController.h +// RDVCalendarView // -// RDVCalendarViewController.h -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import #import "RDVCalendarView.h" @@ -12,6 +27,6 @@ @interface RDVCalendarViewController : UIViewController @property (nonatomic) RDVCalendarView *calendarView; -@property (nonatomic) NSDate *selectedDate; +@property (nonatomic) BOOL clearsSelectionOnViewWillAppear; @end diff --git a/RDVCalendarView/RDVCalendarViewController.m b/RDVCalendarView/RDVCalendarViewController.m index 422099d..62504e6 100644 --- a/RDVCalendarView/RDVCalendarViewController.m +++ b/RDVCalendarView/RDVCalendarViewController.m @@ -1,24 +1,30 @@ +// RDVCalendarViewController.m +// RDVCalendarView // -// RDVCalendarViewController.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/16/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "RDVCalendarViewController.h" @implementation RDVCalendarViewController -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - - } - return self; -} - #pragma mark - View lifecycle - (void)loadView { @@ -41,7 +47,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa #pragma mark - RDVCalendarViewDelegate - (void)calendarView:(RDVCalendarView *)calendarView didSelectDate:(NSDate *)date { - [self setSelectedDate:date]; + } @end diff --git a/RDVCalendarView/RDVCalendarWeekDaysHeader.h b/RDVCalendarView/RDVCalendarWeekDaysHeader.h index f23de0b..4b95a68 100644 --- a/RDVCalendarView/RDVCalendarWeekDaysHeader.h +++ b/RDVCalendarView/RDVCalendarWeekDaysHeader.h @@ -1,10 +1,25 @@ +// RDVCalendarWeekDaysHeader.h +// RDVCalendarView // -// RDVCalendarWeekDaysHeader.h -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/26/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import diff --git a/RDVCalendarView/RDVCalendarWeekDaysHeader.m b/RDVCalendarView/RDVCalendarWeekDaysHeader.m index eaa36c2..82507eb 100644 --- a/RDVCalendarView/RDVCalendarWeekDaysHeader.m +++ b/RDVCalendarView/RDVCalendarWeekDaysHeader.m @@ -1,10 +1,25 @@ +// RDVCalendarWeekDaysHeader.m +// RDVCalendarView // -// RDVCalendarWeekDaysHeader.m -// RDVCalendarView +// Copyright (c) 2013 Robert Dimitrov // -// Created by Robert Dimitrov on 8/26/13. -// Copyright (c) 2013 Robert Dimitrov. All rights reserved. +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. #import "RDVCalendarWeekDaysHeader.h"