https://github.com/marcbruins/fscalendar-xamarin-ios
Binding for FSCalendar
https://github.com/marcbruins/fscalendar-xamarin-ios
ios xamarin
Last synced: 14 days ago
JSON representation
Binding for FSCalendar
- Host: GitHub
- URL: https://github.com/marcbruins/fscalendar-xamarin-ios
- Owner: MarcBruins
- License: mit
- Created: 2016-12-28T14:25:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T10:20:11.000Z (over 2 years ago)
- Last Synced: 2025-04-13T22:51:26.634Z (19 days ago)
- Topics: ios, xamarin
- Language: Objective-C
- Size: 7.5 MB
- Stars: 36
- Watchers: 5
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# This is a Xamarin iOS binding for https://github.com/WenchaoD/FSCalendar

[](https://cocoapods.org/pods/FSCalendar)
[](https://cocoapods.org/pods/FSCalendar)
[](https://travis-ci.org/WenchaoD/FSCalendar)
[](http://cocoadocs.org/docsets/FSCalendar)
[](http://cocoadocs.org/docsets/FSCalendar)
[](https://github.com/Carthage/Carthage)
[](#)# Updates
* [NSCalendarExtension](https://github.com/WenchaoD/NSCalendarExtension) is required to get iOS7 compatibility.
# Table of contents
* [Screenshots](#screenshots)
* [Installation](#installation)
* [Pre-knowledge](#pre-knowledge)
* [Support](#support)
* [Contact](#contact)
## iPhone
## iPad
## Safe Orientation
## Today Extension
| iOS8/9 | iOS10 |
|--------------|-------------|
|||## DIY support
|  |
| ------------- |
> To customize your own cell, view DIY Example in `Example-Swift` or `Example-Objc`## Swipe-To-Choose
|Single-Selection
Swipe-To-Choose|Multiple-Selection
Swipe-To-Choose|DIY
Swipe-To-Choose|
|----------|--------|--------|
||||## CocoaPods:
* For iOS8+: 👍
```ruby
use_frameworks!
pod 'FSCalendar'
```* For iOS7+:
```ruby
pod 'FSCalendar'
```> [NSCalendarExtension](https://github.com/WenchaoD/NSCalendarExtension) is required to get iOS7 compatibility.
* Alternatively to give it a test run, run the command:
```ruby
pod try FSCalendar
```## Carthage:
* For iOS8+```ruby
github "WenchaoD/FSCalendar"
```## Manually:
* Drag all files under `FSCalendar` folder into your project. 👍## Support IBInspectable / IBDesignable
Only the methods marked "👍" support IBInspectable / IBDesignable feature. [Have fun with Interface builder](#roll_with_interface_builder)# Setup
## Use Interface Builder
1. Drag an UIView object to ViewController Scene
2. Change the `Custom Class` to `FSCalendar`
3. Link `dataSource` and `delegate` to the ViewController
4. Finally, you should implement `FSCalendarDataSource` and `FSCalendarDelegate` in ViewController.m
## Or use code
```objc
@property (weak , nonatomic) FSCalendar *calendar;
```
```objc
// In loadView(Recommended) or viewDidLoad
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
calendar.dataSource = self;
calendar.delegate = self;
[self.view addSubview:calendar];
self.calendar = calendar;
```## Or swift
* To use `FSCalendar` in swift, you need to [Create Bridge Header](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) first.
```swift
private weak var calendar: FSCalendar!
```
```swift
// In loadView or viewDidLoad
let calendar = FSCalendar(frame: CGRect(x: 0, y: 0, width: 320, height: 300))
calendar.dataSource = self
calendar.delegate = self
view.addSubview(calendar)
self.calendar = calendar
```> To use **FSCalendar** in Swift3, see `Example-Swift` for details.
## Warning
`FSCalendar` doesn't change frame by itself, Please implement* For autoLayout
```objc
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
_calendarHeightConstraint.constant = CGRectGetHeight(bounds);
[self.view layoutIfNeeded];
}
```* For manual layout
```objc
- (void)calendar:(FSCalendar *)calendar boundingRectWillChange:(CGRect)bounds animated:(BOOL)animated
{
calendar.frame = (CGRect){calendar.frame.origin,bounds.size};
}
```### Roll with Interface Builder
> In `Swift3`, `NSDate` and `NSDateFormatter` have been renamed to ***Date*** and ***DateFormatter*** , see `SwiftExample` for details.
## How to create NSDate object
* By **NSCalendar**.
```objc
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
```Then:
```objc
NSDate *date = [gregorian dateWithEra:1 year:2016 month:9 day:10 hour:0 minute:0 second:0 nanosecond:0];
// 2016-09-10 00:00:00
```* Or by **NSDateFormatter**
```objc
self.formatter = [[NSDateFormatter alloc] init];
self.formatter.dateFormat = @"yyyy-MM-dd";
```Then:
```objc
NSDate *date = [self.formatter dateFromString:@"2016-09-10"];
```## How to print out NSDate object
* Use **NSDateFormatter**
```objc
self.formatter = [[NSDateFormatter alloc] init];
self.formatter.dateFormat = @"yyyy/MM/dd";
``````objc
NSString *string = [self.formatter stringFromDate:date];
NSLog(@"Date is %@", string);
```## How to manipulate NSDate with NSCalendar
```objc
self.gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
```
* Get component of NSDate```objc
NSInteger era = [self.gregorian component:NSCalendarUnitEra fromDate:date];
NSInteger year = [self.gregorian component:NSCalendarUnitYear fromDate:date];
NSInteger month = [self.gregorian component:NSCalendarUnitMonth fromDate:date];
NSInteger day = [self.gregorian component:NSCalendarUnitDay fromDate:date];
NSInteger hour = [self.gregorian component:NSCalendarUnitHour fromDate:date];
NSInteger minute = [self.gregorian component:NSCalendarUnitMinute fromDate:date];
...```
* Get next **month**
```objc
NSDate *nextMonth = [self.gregorain dateByAddingUnit:NSCalendarUnitMonth value:1 toDate:date options:0];
```* Get next **day**
```objc
NSDate *nextDay = [self.gregorain dateByAddingUnit:NSCalendarUnitDay value:1 toDate:date options:0];
```* Is date in today/tomorrow/yesterday/weekend
```objc
BOOL isToday = [self.gregorian isDateInToday:date];
BOOL isYesterday = [self.gregorian isDateInYesterday:date];
BOOL isTomorrow = [self.gregorian isDateInTomorrow:date];
BOOL isWeekend = [self.gregorian isDateInWeekend:date];
```* Compare two dates
```objc
BOOL sameDay = [self.gregorian isDate:date1 inSameDayAsDate:date2];
// Yes if the date1 and date2 are in same day[self.gregorian compareDate:date1 toDate:date2 toUnitGranularity:unit];
// compare the era/year/month/day/hour/minute .etc ...
// return NSOrderAscending/NSOrderSame/NSOrderDecendingBOOL inSameUnit = [self.gregorian isDate:date1 equalToDate:date2 toUnitGranularity:unit];
// if the given unit (era/year/month/day/hour/minute .etc) are the same```
## Support this repo
* ***Star*** this repo![]()
* Support with![]()
* Support withor
## Contact
* 微博: [**@WenchaoD**](http://weibo.com/WenchaoD)
* Twitter:[**@WenchaoD**](https://twitter.com/WenchaoD)
* QQ支持群:
> If your made a beautiful calendar with this library in your app, please take a screen shot and [@me](https://twitter.com/WenchaoD) in twitter. Your help really means a lot to me!
> 如果你用这个库完成了一个外观漂亮的日历,希望你能将这个漂亮的日历截图在微博中[@我](http://weibo.com/WenchaoD),十分感谢!# License
FSCalendar is available under the MIT license. See the LICENSE file for more info.###[Documentation](http://cocoadocs.org/docsets/FSCalendar/) | [More Usage](https://github.com/WenchaoD/FSCalendar/blob/master/MOREUSAGE.md) | [简书](http://www.jianshu.com/notebooks/4276521/latest)