├── WSCalendar_1.png
├── WSCalendar_2.png
├── WSCalendar.xcodeproj
├── xcuserdata
│ └── dotsquares.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── WSCalendar.xcscheme
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── WSCalendar
├── WSLabel.h
├── WSEventView.h
├── AppDelegate.h
├── main.m
├── WSLabel.m
├── ViewController.h
├── WSEventView.m
├── Info.plist
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── AppDelegate.m
├── WSCalendarView.h
├── ViewController.m
├── WSCalendarView.m
└── WSCalendarView.xib
├── README.md
├── WSCalendarTests
├── Info.plist
└── WSCalendarTests.m
└── WSCalendarUITests
├── Info.plist
└── WSCalendarUITests.m
/WSCalendar_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WebsoftProfession/WSCalendar/HEAD/WSCalendar_1.png
--------------------------------------------------------------------------------
/WSCalendar_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/WebsoftProfession/WSCalendar/HEAD/WSCalendar_2.png
--------------------------------------------------------------------------------
/WSCalendar.xcodeproj/xcuserdata/dotsquares.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/WSCalendar.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WSCalendar/WSLabel.h:
--------------------------------------------------------------------------------
1 | //
2 | // WSLabel.h
3 | // CalendarDemo
4 | //
5 | // Created by Dotsquares on 2/15/17.
6 | // Copyright © 2017 Dotsquares. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WSLabel : UILabel
12 |
13 | @property (nonatomic,strong) NSDate *linkedDate;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/WSCalendar/WSEventView.h:
--------------------------------------------------------------------------------
1 | //
2 | // WSEventView.h
3 | // CalendarDemo
4 | //
5 | // Created by Dotsquares on 2/16/17.
6 | // Copyright © 2017 Dotsquares. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WSEventView : UIView
12 | @property (nonatomic,strong) UIColor *eventColor;
13 | -(void)setEventViewColor:(UIColor *)color;
14 | @end
15 |
--------------------------------------------------------------------------------
/WSCalendar/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // WSCalendar
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. 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 |
--------------------------------------------------------------------------------
/WSCalendar/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // WSCalendar
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. 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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WSCalendarViewSwift
2 |
3 | Swift Version is Available now
4 |
5 | https://github.com/WebsoftProfession/WSCalendarViewSwift
6 |
7 | # WSCalendar
8 | Calendar for use Event and Date picker with good appearance and easy to use.
9 |
10 | 
11 | 
12 |
--------------------------------------------------------------------------------
/WSCalendar/WSLabel.m:
--------------------------------------------------------------------------------
1 | //
2 | // WSLabel.m
3 | // CalendarDemo
4 | //
5 | // Created by Dotsquares on 2/15/17.
6 | // Copyright © 2017 Dotsquares. All rights reserved.
7 | //
8 |
9 | #import "WSLabel.h"
10 |
11 | @implementation WSLabel
12 |
13 | /*
14 | // Only override drawRect: if you perform custom drawing.
15 | // An empty implementation adversely affects performance during animation.
16 | - (void)drawRect:(CGRect)rect {
17 | // Drawing code
18 | }
19 | */
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/WSCalendar/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // WSCalendar
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WSCalendarView.h"
11 |
12 | @interface ViewController : UIViewController
13 |
14 | @property (weak, nonatomic) IBOutlet UITextField *txtCalender;
15 | @property (weak, nonatomic) IBOutlet UIView *containerView;
16 |
17 | @end
18 |
19 |
--------------------------------------------------------------------------------
/WSCalendar/WSEventView.m:
--------------------------------------------------------------------------------
1 | //
2 | // WSEventView.m
3 | // CalendarDemo
4 | //
5 | // Created by Dotsquares on 2/16/17.
6 | // Copyright © 2017 Dotsquares. All rights reserved.
7 | //
8 |
9 | #import "WSEventView.h"
10 |
11 | @implementation WSEventView
12 |
13 | /*
14 | // Only override drawRect: if you perform custom drawing.
15 | // An empty implementation adversely affects performance during animation.*/
16 | - (void)drawRect:(CGRect)rect {
17 | // Drawing code
18 | }
19 |
20 | -(void)setEventViewColor:(UIColor *)color{
21 | self.clipsToBounds=YES;
22 | self.backgroundColor = color;
23 | self.layer.cornerRadius=self.frame.size.width/2;
24 | }
25 |
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/WSCalendarTests/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 |
--------------------------------------------------------------------------------
/WSCalendarUITests/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 |
--------------------------------------------------------------------------------
/WSCalendar.xcodeproj/xcuserdata/dotsquares.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | WSCalendar.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 60C595801EA8D1B800886597
16 |
17 | primary
18 |
19 |
20 | 60C595991EA8D1BB00886597
21 |
22 | primary
23 |
24 |
25 | 60C595A41EA8D1BB00886597
26 |
27 | primary
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/WSCalendarTests/WSCalendarTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // WSCalendarTests.m
3 | // WSCalendarTests
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WSCalendarTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation WSCalendarTests
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 |
--------------------------------------------------------------------------------
/WSCalendarUITests/WSCalendarUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // WSCalendarUITests.m
3 | // WSCalendarUITests
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WSCalendarUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation WSCalendarUITests
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 |
--------------------------------------------------------------------------------
/WSCalendar/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 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/WSCalendar/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 |
--------------------------------------------------------------------------------
/WSCalendar/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | }
88 | ],
89 | "info" : {
90 | "version" : 1,
91 | "author" : "xcode"
92 | }
93 | }
--------------------------------------------------------------------------------
/WSCalendar/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // WSCalendar
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. 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 |
--------------------------------------------------------------------------------
/WSCalendar/WSCalendarView.h:
--------------------------------------------------------------------------------
1 | //
2 | // CalendarView.h
3 | // CalendarDemo
4 | //
5 | // Created by Dotsquares on 3/9/16.
6 | // Copyright © 2016 Dotsquares. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WSLabel.h"
11 | #import "WSEventView.h"
12 |
13 |
14 | typedef enum {
15 | WSCalendarStyleDialog=0,
16 | WSCalendarStyleView=1,
17 | }WSCalendarStyle;
18 |
19 | @protocol WSCalendarViewDelegate
20 | -(void)didTapLabel:(WSLabel *)lblView withDate:(NSDate *)selectedDate;
21 | -(void)deactiveWSCalendarWithDate:(NSDate *)selectedDate;
22 | -(NSArray *)setupEventForDate;
23 | @end
24 |
25 |
26 | @interface WSCalendarView : UIView
27 | {
28 |
29 | __weak IBOutlet UIBarButtonItem *barBtnYear;
30 | __weak IBOutlet UIBarButtonItem *barBtnMonth;
31 |
32 | __weak IBOutlet UIBarButtonItem *btnBarDate;
33 |
34 | __weak IBOutlet UILabel *lblDate1;
35 | __weak IBOutlet UILabel *lblDate2;
36 | __weak IBOutlet UILabel *lblDate3;
37 | __weak IBOutlet UILabel *lblDate4;
38 | __weak IBOutlet UILabel *lblDate5;
39 | __weak IBOutlet UILabel *lblDate6;
40 | __weak IBOutlet UILabel *lblDate7;
41 | __weak IBOutlet UILabel *lblDate8;
42 | __weak IBOutlet UILabel *lblDate9;
43 | __weak IBOutlet UILabel *lblDate10;
44 | __weak IBOutlet UILabel *lblDate11;
45 | __weak IBOutlet UILabel *lblDate12;
46 | __weak IBOutlet UILabel *lblDate13;
47 | __weak IBOutlet UILabel *lblDate14;
48 | __weak IBOutlet UILabel *lblDate15;
49 | __weak IBOutlet UILabel *lblDate16;
50 | __weak IBOutlet UILabel *lblDate17;
51 | __weak IBOutlet UILabel *lblDate18;
52 | __weak IBOutlet UILabel *lblDate19;
53 | __weak IBOutlet UILabel *lblDate20;
54 | __weak IBOutlet UILabel *lblDate21;
55 | __weak IBOutlet UILabel *lblDate22;
56 | __weak IBOutlet UILabel *lblDate23;
57 | __weak IBOutlet UILabel *lblDate24;
58 | __weak IBOutlet UILabel *lblDate25;
59 | __weak IBOutlet UILabel *lblDate26;
60 | __weak IBOutlet UILabel *lblDate27;
61 | __weak IBOutlet UILabel *lblDate28;
62 | __weak IBOutlet UILabel *lblDate29;
63 | __weak IBOutlet UILabel *lblDate30;
64 | __weak IBOutlet UILabel *lblDate31;
65 | __weak IBOutlet UILabel *lblWeekDate;
66 |
67 |
68 | UITextField *activeTextField;
69 | WSLabel *activeLabel;
70 |
71 | }
72 |
73 | -(void)initializeMonthYear;
74 |
75 | -(void)setMonth:(NSString *)month andYear:(NSString *)year;
76 | - (IBAction)yearNextClicked:(id)sender;
77 | - (IBAction)yearPrevClicked:(id)sender;
78 | - (IBAction)NextClicked:(id)sender;
79 | - (IBAction)PrevClicked:(id)sender;
80 |
81 | -(void)reloadCalendar;
82 |
83 | @property (nonatomic,strong) id delegate;
84 | -(void)setupAppearance;
85 | -(void)ActiveCalendar:(UIView *)view;
86 |
87 |
88 | @property (assign) int calendarStyle;
89 | @property (assign) BOOL isShowEvent;
90 | @property (nonatomic,strong) UIColor *dayColor;
91 | @property (nonatomic,strong) UIColor *weekDayNameColor;
92 | @property (nonatomic,strong) UIColor *barDateColor;
93 | @property (nonatomic,strong) UIColor *todayBackgroundColor;
94 | @property (nonatomic,strong) UIColor *tappedDayBackgroundColor;
95 |
96 |
97 |
98 |
99 | - (IBAction)cancelAction:(id)sender;
100 | - (IBAction)okAciton:(id)sender;
101 | @property (weak, nonatomic) IBOutlet UIButton *btnCancel;
102 | @property (weak, nonatomic) IBOutlet UIButton *btnOK;
103 |
104 |
105 | @end
106 |
--------------------------------------------------------------------------------
/WSCalendar/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // WSCalendar
4 | //
5 | // Created by Dotsquares on 4/20/17.
6 | // Copyright © 2017 WebsoftProfession. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 |
12 | @interface ViewController ()
13 | {
14 | WSCalendarView *calendarView;
15 | WSCalendarView *calendarViewEvent;
16 | NSMutableArray *eventArray;
17 | }
18 | @end
19 |
20 | @implementation ViewController
21 |
22 | - (void)viewDidLoad {
23 | [super viewDidLoad];
24 | // Do any additional setup after loading the view, typically from a nib.
25 | calendarView = [[[NSBundle mainBundle] loadNibNamed:@"WSCalendarView" owner:self options:nil] firstObject];
26 | //calendarView.dayColor=[UIColor blackColor];
27 | //calendarView.weekDayNameColor=[UIColor purpleColor];
28 | //calendarView.barDateColor=[UIColor purpleColor];
29 | //calendarView.todayBackgroundColor=[UIColor blackColor];
30 | calendarView.tappedDayBackgroundColor=[UIColor blackColor];
31 | calendarView.calendarStyle = WSCalendarStyleDialog;
32 | calendarView.isShowEvent=false;
33 | [calendarView setupAppearance];
34 | [self.view addSubview:calendarView];
35 | calendarView.delegate=self;
36 |
37 |
38 | calendarViewEvent = [[[NSBundle mainBundle] loadNibNamed:@"WSCalendarView" owner:self options:nil] firstObject];
39 | calendarViewEvent.calendarStyle = WSCalendarStyleView;
40 | calendarViewEvent.isShowEvent=true;
41 | calendarViewEvent.tappedDayBackgroundColor=[UIColor blackColor];
42 | calendarViewEvent.frame = CGRectMake(0, 0, self.containerView.frame.size.width, self.containerView.frame.size.height);
43 | [calendarViewEvent setupAppearance];
44 | calendarViewEvent.delegate=self;
45 | [self.containerView addSubview:calendarViewEvent];
46 |
47 |
48 | eventArray=[[NSMutableArray alloc] init];
49 | NSDate *lastDate;
50 | NSDateComponents *dateComponent=[[NSDateComponents alloc] init];
51 | for (int i=0; i<10; i++) {
52 |
53 | if (!lastDate) {
54 | lastDate=[NSDate date];
55 | }
56 | else{
57 | [dateComponent setDay:1];
58 | }
59 | NSDate *datein = [[NSCalendar currentCalendar] dateByAddingComponents:dateComponent toDate:lastDate options:0];
60 | lastDate=datein;
61 | [eventArray addObject:datein];
62 | }
63 | [calendarViewEvent reloadCalendar];
64 |
65 | NSLog(@"%@",[eventArray description]);
66 | }
67 |
68 | -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
69 | {
70 | [calendarView ActiveCalendar:textField];
71 | return YES;
72 | }
73 |
74 | -(void)textFieldDidBeginEditing:(UITextField *)textField
75 | {
76 |
77 | }
78 |
79 | #pragma mark WSCalendarViewDelegate
80 |
81 | -(NSArray *)setupEventForDate{
82 | return eventArray;
83 | }
84 |
85 | -(void)didTapLabel:(WSLabel *)lblView withDate:(NSDate *)selectedDate
86 | {
87 |
88 | }
89 |
90 | -(void)deactiveWSCalendarWithDate:(NSDate *)selectedDate{
91 | NSDateFormatter *monthFormatter=[[NSDateFormatter alloc] init];
92 | [monthFormatter setDateFormat:@"dd MMMM yyyy"];
93 | NSString *str=[monthFormatter stringFromDate:selectedDate];
94 | self.txtCalender.text = str;
95 | }
96 |
97 |
98 | - (IBAction)hideKeyboard:(id)sender {
99 |
100 | [self.view endEditing:YES];
101 | }
102 |
103 | - (void)didReceiveMemoryWarning {
104 | [super didReceiveMemoryWarning];
105 | // Dispose of any resources that can be recreated.
106 | }
107 |
108 |
109 | @end
110 |
--------------------------------------------------------------------------------
/WSCalendar.xcodeproj/xcuserdata/dotsquares.xcuserdatad/xcschemes/WSCalendar.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 |
--------------------------------------------------------------------------------
/WSCalendar/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 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/WSCalendar/WSCalendarView.m:
--------------------------------------------------------------------------------
1 | //
2 | // CalendarView.m
3 | // CalendarDemo
4 | //
5 | // Created by Dotsquares on 3/9/16.
6 | // Copyright © 2016 Dotsquares. All rights reserved.
7 | //
8 |
9 | #import "WSCalendarView.h"
10 |
11 | @implementation WSCalendarView
12 | {
13 | NSMutableArray *dayInMonth;
14 | NSMutableArray *completeDateArray;
15 | NSArray *lblArray;
16 | BOOL isLoop;
17 | BOOL is;
18 | NSDate *selectedDate;
19 | }
20 |
21 | @synthesize dayColor=_dayColor;
22 | @synthesize weekDayNameColor=_weekDayNameColor;
23 | @synthesize barDateColor=_barDateColor;
24 | @synthesize todayBackgroundColor=_todayBackgroundColor;
25 | @synthesize tappedDayBackgroundColor=_tappedDayBackgroundColor;
26 |
27 | /*
28 | // Only override drawRect: if you perform custom drawing.
29 | // An empty implementation adversely affects performance during animation.
30 | - (void)drawRect:(CGRect)rect {
31 | // Drawing code
32 | }
33 | */
34 |
35 | -(void)setupAppearance{
36 |
37 | if (self.calendarStyle == WSCalendarStyleDialog) {
38 | self.hidden=YES;
39 | self.clipsToBounds=YES;
40 | self.layer.cornerRadius=5.0;
41 | self.layer.borderColor=[UIColor grayColor].CGColor;
42 | self.layer.borderWidth=1.0;
43 |
44 | }
45 | else{
46 | self.btnCancel.hidden=YES;
47 | self.btnOK.hidden=YES;
48 | }
49 |
50 | [self initializeMonthYear];
51 | }
52 |
53 | -(void)initializeMonthYear
54 | {
55 | lblArray=[[NSArray alloc] initWithObjects:lblDate1,lblDate2,lblDate3,lblDate4,lblDate5,lblDate6,lblDate7,lblDate8,lblDate9,lblDate10,lblDate11,lblDate12,lblDate13,lblDate14,lblDate15,lblDate16,lblDate17,lblDate18,lblDate19,lblDate20,lblDate21,lblDate22,lblDate23,lblDate24,lblDate25,lblDate26,lblDate27,lblDate28,lblDate29,lblDate30,lblDate31, nil];
56 | isLoop=YES;
57 | is=YES;
58 | dayInMonth=[[NSMutableArray alloc] init];
59 | completeDateArray=[[NSMutableArray alloc] init];
60 |
61 | NSDate *currentDate=[NSDate date];
62 | [self setLabelCircle:currentDate];
63 | for (int i=0; i<31 ; i++) {
64 |
65 | UILabel *lbl=[lblArray objectAtIndex:i];
66 |
67 | lbl.tag=i;
68 |
69 | UITapGestureRecognizer *tapG=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lblTapped:)];
70 | [lbl addGestureRecognizer:tapG];
71 | }
72 | selectedDate=[NSDate date];
73 | [self setWeekDateLabel:selectedDate];
74 | [self setYear:selectedDate];
75 | [self numberOfYearsInCalendar];
76 |
77 | [self setMonthLabels:currentDate];
78 | }
79 |
80 | -(void)reloadCalendar{
81 | [self setMonthLabels:selectedDate];
82 | }
83 |
84 | -(void)removeLabelCircle:(NSDate *)currentDate
85 | {
86 | BOOL isTodayMonth = false;
87 | if ([self dateStringMatching:currentDate]) {
88 | isTodayMonth=true;
89 | }
90 | NSDateFormatter *monthFormatter=[[NSDateFormatter alloc] init];
91 | [monthFormatter setDateFormat:@"dd"];
92 | NSString *str=[monthFormatter stringFromDate:currentDate];
93 |
94 | for (int i=0; i<31 ; i++) {
95 |
96 | WSLabel *lbl=[lblArray objectAtIndex:i];
97 | lbl.layer.cornerRadius=lbl.frame.size.width/2;
98 | lbl.layer.borderWidth=2.0;
99 |
100 | if (isTodayMonth) {
101 | if ([lbl.text isEqualToString:str]) {
102 | lbl.layer.borderColor=[UIColor clearColor].CGColor;
103 | if (self.todayBackgroundColor) {
104 | lbl.backgroundColor=self.todayBackgroundColor;
105 | }
106 | else{
107 | lbl.backgroundColor=[UIColor lightGrayColor];
108 | }
109 |
110 | }
111 | else{
112 | lbl.layer.borderColor=[UIColor clearColor].CGColor;
113 | lbl.backgroundColor=[UIColor clearColor];
114 | }
115 | }
116 | else{
117 |
118 | lbl.layer.borderColor=[UIColor clearColor].CGColor;
119 | lbl.backgroundColor=[UIColor clearColor];
120 | }
121 |
122 | if (self.isShowEvent) {
123 | [self generateEventOnView:lbl];
124 | }
125 |
126 |
127 | }
128 | }
129 |
130 | -(void)generateEventOnView:(WSLabel *)dayView{
131 | [[dayView subviews]makeObjectsPerformSelector:@selector(removeFromSuperview)];
132 | if([self.delegate respondsToSelector:@selector(setupEventForDate)]){
133 | NSArray *eventArray = [self.delegate setupEventForDate];
134 | if (eventArray.count>0) {
135 | for (int k = 0; kcurrentDayValue) {
256 |
257 | NSDate *newSelectedDate=selectedDate;
258 |
259 | for (int i=currentDayValue; iinterDate; i--) {
278 |
279 | NSDateComponents *dc = [[NSDateComponents alloc] init];
280 | [dc setDay:-1];
281 | NSDate *datein = [[NSCalendar currentCalendar] dateByAddingComponents:dc toDate:newSelectedDate options:0];
282 | newSelectedDate=datein;
283 | NSDateFormatter *monthFormatter=[[NSDateFormatter alloc] init];
284 | [monthFormatter setDateFormat:@"dd MMMM YYYY"];
285 | [btnBarDate setTitle:[monthFormatter stringFromDate:datein]];
286 | [self setWeekDateLabel:datein];
287 |
288 | NSLog(@"%d",currentDayValue);
289 |
290 | }
291 | }
292 | else{
293 | NSDateFormatter *monthFormatter=[[NSDateFormatter alloc] init];
294 | [monthFormatter setDateFormat:@"dd MMMM YYYY"];
295 | [btnBarDate setTitle:[monthFormatter stringFromDate:[NSDate date]]];
296 | [self setWeekDateLabel:selectedDate];
297 | }
298 | activeLabel = lbl;
299 | [self.delegate didTapLabel:lbl withDate:lbl.linkedDate];
300 | }
301 |
302 | -(void)numberOfYearsInCalendar
303 | {
304 | NSDate *calendarDate=[NSDate date];
305 | [completeDateArray addObject:calendarDate];
306 | for (int i=0; i<365; i++) {
307 | NSDateComponents *dc = [[NSDateComponents alloc] init];
308 | [dc setMonth:0];
309 | [dc setDay:1];
310 | NSDate *datein = [[NSCalendar currentCalendar] dateByAddingComponents:dc toDate:calendarDate options:0];
311 | calendarDate=datein;
312 | [completeDateArray addObject:datein];
313 |
314 | }
315 | }
316 |
317 | -(void)setMonthLabels:(NSDate *)date
318 | {
319 | [dayInMonth removeAllObjects];
320 | NSDate *currentDate=date;
321 |
322 | NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
323 | [dateFormatter1 setDateFormat:@"dd"];
324 | int currentDayValue=[[dateFormatter1 stringFromDate:currentDate] intValue];
325 | for (int i=currentDayValue; i>1; i--) {
326 |
327 | NSDateComponents *dc = [[NSDateComponents alloc] init];
328 | [dc setDay:-1];
329 | NSDate *datein = [[NSCalendar currentCalendar] dateByAddingComponents:dc toDate:currentDate options:0];
330 | currentDate=datein;
331 | NSLog(@"%d",currentDayValue);
332 | }
333 |
334 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
335 | [dateFormatter setDateFormat:@"dd"];
336 | int currentDayValue1=[[dateFormatter stringFromDate:currentDate] intValue];
337 | NSLog(@"%d",currentDayValue);
338 |
339 | NSDateComponents *dc = [[NSDateComponents alloc] init];
340 | [dc setMonth:1];
341 | NSDate *endDate = [[NSCalendar currentCalendar] dateByAddingComponents:dc toDate:currentDate options:0];
342 | NSDateFormatter *endDateFormatter = [[NSDateFormatter alloc] init];
343 | [endDateFormatter setDateFormat:@"dd MMMM"];
344 | NSString *endDateString=[endDateFormatter stringFromDate:endDate];
345 |
346 | [dayInMonth addObject:currentDate];
347 | for (int i=0; i<30; i++) {
348 |
349 | NSDateComponents *dc = [[NSDateComponents alloc] init];
350 | [dc setDay:1];
351 | NSDate *datein = [[NSCalendar currentCalendar] dateByAddingComponents:dc toDate:currentDate options:0];
352 | currentDate=datein;
353 | [dayInMonth addObject:datein];
354 |
355 | }
356 |
357 | for (int i=0; i<31; i++) {
358 | UILabel *lbl=[lblArray objectAtIndex:i];
359 | lbl.hidden=YES;
360 | }
361 |
362 | for (int i=0; i
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
30 |
37 |
44 |
51 |
58 |
65 |
72 |
79 |
89 |
99 |
109 |
119 |
129 |
139 |
149 |
159 |
169 |
179 |
189 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
244 |
254 |
264 |
274 |
284 |
294 |
304 |
314 |
324 |
334 |
344 |
354 |
364 |
374 |
384 |
394 |
404 |
415 |
416 |
417 |
418 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
447 |
460 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
--------------------------------------------------------------------------------