Skip to content

Commit 562774d

Browse files
author
Vũ Đức Tuyến
authored
Create README.md
1 parent f6d5336 commit 562774d

File tree

1 file changed

+220
-0
lines changed

1 file changed

+220
-0
lines changed

README.md

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
FSCalendar - Xamarin iOS Binding Library
2+
=====
3+
4+
![logo](https://cloud.githubusercontent.com/assets/5186464/16540124/efc51f72-408b-11e6-934a-4e750b8b55bb.png)
5+
6+
# Table of contents
7+
* [Screenshots](#screenshots)
8+
* [Installation](#installation)
9+
* [Pre-knowledge](#pre-knowledge)
10+
11+
## <a id="screenshots"></a>Screenshots
12+
13+
### iPhone
14+
![fscalendar](https://cloud.githubusercontent.com/assets/5186464/10262249/4fabae40-69f2-11e5-97ab-afbacd0a3da2.jpg)
15+
16+
### iPad
17+
![fscalendar-ipad](https://cloud.githubusercontent.com/assets/5186464/10927681/d2448cb6-82dc-11e5-9d11-f664a06698a7.jpg)
18+
19+
### Safe Orientation
20+
![fscalendar-scope-orientation-autolayout](https://cloud.githubusercontent.com/assets/5186464/20325758/ea125e1e-abc0-11e6-9e29-491acbcb0d07.gif)
21+
22+
### Today Extension
23+
| iOS8/9 | iOS10 |
24+
|--------------|-------------|
25+
|![today1](https://cloud.githubusercontent.com/assets/5186464/20288375/ed3fba0e-ab0d-11e6-8b15-43d3dc656f22.gif)|![today2](https://cloud.githubusercontent.com/assets/5186464/20288378/f11e318c-ab0d-11e6-8d1d-9d89b563e9d7.gif)|
26+
27+
### Interactive Scope Gesture
28+
| ![1](https://cloud.githubusercontent.com/assets/5186464/21559640/e92a9ccc-ce8a-11e6-8c60-e52204f33249.gif) |
29+
| ---- |
30+
31+
### DIY support
32+
| ![1](https://cloud.githubusercontent.com/assets/5186464/20026983/22354a0e-a342-11e6-8ae6-0614ea7f35ae.gif) |
33+
| ------------- |
34+
> To customize your own cell, view DIY Example in `Example-Swift` or `Example-Objc`
35+
36+
37+
### Swipe-To-Choose
38+
39+
|Single-Selection<br/>Swipe-To-Choose|Multiple-Selection<br/>Swipe-To-Choose|DIY<br/>Swipe-To-Choose|
40+
|----------|--------|--------|
41+
|![1](https://cloud.githubusercontent.com/assets/5186464/20257768/cb1905d4-aa86-11e6-9ef7-af76f9caa024.gif)|![2](https://cloud.githubusercontent.com/assets/5186464/20257826/254070ec-aa87-11e6-81b1-1815453fd464.gif)|![3](https://cloud.githubusercontent.com/assets/5186464/20257836/2ffa3252-aa87-11e6-8ff9-3b40f5b2307b.gif)|
42+
43+
## Achievement of Users <a id="achievement"></a>
44+
45+
| ![1](https://cloud.githubusercontent.com/assets/5186464/21747193/3111e4ee-d59a-11e6-8e4d-ca695b53e421.png) | ![2](https://cloud.githubusercontent.com/assets/5186464/21747393/42a753fa-d5a0-11e6-9cb2-de7cc642e69e.png) | ![3](https://cloud.githubusercontent.com/assets/5186464/21897255/ff78fcdc-d923-11e6-9d59-62119bc4343f.png) | ![4](https://cloud.githubusercontent.com/assets/5186464/21747192/3111cacc-d59a-11e6-8626-44cd75ebd794.png) |
46+
| ------------- | ------------- | ------------- | ------------- |
47+
48+
#### [***More Achievements***](https://github.com/WenchaoD/FSCalendar/wiki/) are available in [***FSCalendar Gallery***](https://github.com/WenchaoD/FSCalendar/wiki/)
49+
50+
===
51+
52+
# <a id="installation"></a>Installation
53+
```
54+
Install-Package Naxam.FSCalendar.iOS
55+
```
56+
57+
# Setup
58+
59+
## Use Interface Builder
60+
61+
1、 Drag an UIView object to ViewController Scene
62+
2、 Change the `Custom Class` to `FSCalendar`<br/>
63+
3、 Link `dataSource` and `delegate` to the ViewController <br/>
64+
65+
![fscalendar-ib](https://cloud.githubusercontent.com/assets/5186464/9488580/a360297e-4c0d-11e5-8548-ee9274e7c4af.jpg)
66+
67+
4、 Finally, implement `FSCalendarDataSource` and `FSCalendarDelegate` in your `ViewController`
68+
69+
## Or use code
70+
71+
```objc
72+
@property (weak , nonatomic) FSCalendar *calendar;
73+
```
74+
```objc
75+
// In loadView(Recommended) or viewDidLoad
76+
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
77+
calendar.dataSource = self;
78+
calendar.delegate = self;
79+
[self.view addSubview:calendar];
80+
self.calendar = calendar;
81+
```
82+
83+
* For ***AutoLayout***
84+
85+
```objc
86+
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
87+
{
88+
self.calendarHeightConstraint.constant = CGRectGetHeight(bounds);
89+
// Do other updates here
90+
[self.view layoutIfNeeded];
91+
}
92+
```
93+
94+
* For ***Manual Layout***
95+
96+
```objc
97+
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
98+
{
99+
calendar.frame = (CGRect){calendar.frame.origin,bounds.size};
100+
// Do other updates here
101+
}
102+
```
103+
104+
* If you are using ***Masonry***
105+
106+
```objc
107+
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
108+
{
109+
[calendar mas_updateConstraints:^(MASConstraintMaker *make) {
110+
make.height.equalTo(@(bounds.size.height));
111+
// Do other updates
112+
}];
113+
[self.view layoutIfNeeded];
114+
}
115+
```
116+
117+
### <a id="roll_with_interface_builder"></a> Roll with Interface Builder
118+
![fscalendar - ibdesignable](https://cloud.githubusercontent.com/assets/5186464/9301716/2e76a2ca-4503-11e5-8450-1fa7aa93e9fd.gif)
119+
120+
# <a id="pre-knowledge"></a>Pre-knowledge
121+
122+
## How to create NSDate object
123+
124+
* By **NSCalendar**.
125+
126+
```objc
127+
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
128+
```
129+
130+
Then:
131+
132+
```objc
133+
NSDate *date = [gregorian dateWithEra:1 year:2016 month:9 day:10 hour:0 minute:0 second:0 nanosecond:0];
134+
// 2016-09-10 00:00:00
135+
```
136+
137+
138+
* Or by **NSDateFormatter**
139+
140+
```objc
141+
self.formatter = [[NSDateFormatter alloc] init];
142+
self.formatter.dateFormat = @"yyyy-MM-dd";
143+
```
144+
145+
Then:
146+
147+
```objc
148+
NSDate *date = [self.formatter dateFromString:@"2016-09-10"];
149+
```
150+
151+
## How to print out NSDate object
152+
153+
* Use **NSDateFormatter**
154+
155+
```objc
156+
self.formatter = [[NSDateFormatter alloc] init];
157+
self.formatter.dateFormat = @"yyyy/MM/dd";
158+
```
159+
160+
```objc
161+
NSString *string = [self.formatter stringFromDate:date];
162+
NSLog(@"Date is %@", string);
163+
```
164+
165+
## How to manipulate NSDate with NSCalendar
166+
167+
```objc
168+
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
169+
```
170+
* Get component of NSDate
171+
172+
```objc
173+
NSInteger era = [self.gregorian component:NSCalendarUnitEra fromDate:date];
174+
NSInteger year = [self.gregorian component:NSCalendarUnitYear fromDate:date];
175+
NSInteger month = [self.gregorian component:NSCalendarUnitMonth fromDate:date];
176+
NSInteger day = [self.gregorian component:NSCalendarUnitDay fromDate:date];
177+
NSInteger hour = [self.gregorian component:NSCalendarUnitHour fromDate:date];
178+
NSInteger minute = [self.gregorian component:NSCalendarUnitMinute fromDate:date];
179+
...
180+
181+
```
182+
183+
* Get next **month**
184+
185+
```objc
186+
NSDate *nextMonth = [self.gregorain dateByAddingUnit:NSCalendarUnitMonth value:1 toDate:date options:0];
187+
```
188+
189+
* Get next **day**
190+
191+
```objc
192+
NSDate *nextDay = [self.gregorain dateByAddingUnit:NSCalendarUnitDay value:1 toDate:date options:0];
193+
```
194+
195+
* Is date in today/tomorrow/yesterday/weekend
196+
197+
```objc
198+
BOOL isToday = [self.gregorian isDateInToday:date];
199+
BOOL isYesterday = [self.gregorian isDateInYesterday:date];
200+
BOOL isTomorrow = [self.gregorian isDateInTomorrow:date];
201+
BOOL isWeekend = [self.gregorian isDateInWeekend:date];
202+
```
203+
204+
* Compare two dates
205+
206+
```objc
207+
208+
BOOL sameDay = [self.gregorian isDate:date1 inSameDayAsDate:date2];
209+
// Yes if the date1 and date2 are in same day
210+
211+
212+
[self.gregorian compareDate:date1 toDate:date2 toUnitGranularity:unit];
213+
// compare the era/year/month/day/hour/minute .etc ...
214+
// return NSOrderAscending/NSOrderSame/NSOrderDecending
215+
216+
BOOL inSameUnit = [self.gregorian isDate:date1 equalToDate:date2 toUnitGranularity:unit];
217+
// if the given unit (era/year/month/day/hour/minute .etc) are the same
218+
219+
220+
```

0 commit comments

Comments
 (0)