Add delegate methods
1. Add delegate methods
1). `calendar:appearance:titleDefaultColorForDate:`
2). `calendar:appearance:subtitleDefaultColorForDate:`
2. Version bump
3. Add delegate appearance example
This commit is contained in:
parent
105d97e83a
commit
c863aa6bb7
|
|
@ -33,9 +33,33 @@
|
|||
<sections>
|
||||
<tableViewSection id="OKx-qF-6aM">
|
||||
<cells>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="LZ9-Fp-P5z" detailTextLabel="59s-j4-9Zz" style="IBUITableViewCellStyleValue1" id="TLw-G1-xh8">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="lkJ-eR-1Yt" detailTextLabel="sXx-LD-lus" style="IBUITableViewCellStyleValue1" id="P8S-dZ-QEP">
|
||||
<rect key="frame" x="0.0" y="64" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="P8S-dZ-QEP" id="I2e-b6-xVk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Delegate Appearance" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="lkJ-eR-1Yt">
|
||||
<rect key="frame" x="15" y="12" width="157" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Feature!" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="sXx-LD-lus">
|
||||
<rect key="frame" x="525" y="12" width="60" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.87450980389999999" green="0.21960784310000001" blue="0.8900513548951049" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="LZ9-Fp-P5z" detailTextLabel="59s-j4-9Zz" style="IBUITableViewCellStyleValue1" id="TLw-G1-xh8">
|
||||
<rect key="frame" x="0.0" y="108" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="TLw-G1-xh8" id="Wkd-ao-XpQ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
|
|
@ -47,8 +71,8 @@
|
|||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Feature!" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="59s-j4-9Zz">
|
||||
<rect key="frame" x="525" y="12" width="60" height="20"/>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="59s-j4-9Zz">
|
||||
<rect key="frame" x="543" y="12" width="42" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.87450980389999999" green="0.21960784310000001" blue="0.24313725489999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
|
|
@ -58,7 +82,7 @@
|
|||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="vsl-87-uJv" detailTextLabel="HDn-MC-Z72" style="IBUITableViewCellStyleValue1" id="9BE-p1-W4Y">
|
||||
<rect key="frame" x="0.0" y="108" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="152" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9BE-p1-W4Y" id="yDZ-FN-3hk">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
|
|
@ -82,7 +106,7 @@
|
|||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="sRI-B1-vbS" style="IBUITableViewCellStyleDefault" id="hX9-bB-aHp">
|
||||
<rect key="frame" x="0.0" y="152" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="196" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="hX9-bB-aHp" id="Mhd-Y2-O2b">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
|
|
@ -102,7 +126,7 @@
|
|||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="4Jp-Rp-ISm" style="IBUITableViewCellStyleDefault" id="sma-BS-vZ4">
|
||||
<rect key="frame" x="0.0" y="196" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="240" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="sma-BS-vZ4" id="Cyd-80-9BJ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
|
|
@ -122,7 +146,7 @@
|
|||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="A43-g1-NbJ" style="IBUITableViewCellStyleDefault" id="Q8e-18-OC0">
|
||||
<rect key="frame" x="0.0" y="240" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="284" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Q8e-18-OC0" id="S9e-pq-bHQ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
|
|
@ -138,20 +162,27 @@
|
|||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="fKN-25-6hl" style="IBUITableViewCellStyleDefault" id="9cT-ls-dQa">
|
||||
<rect key="frame" x="0.0" y="284" width="600" height="44"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" textLabel="fKN-25-6hl" detailTextLabel="vj2-67-hOL" style="IBUITableViewCellStyleValue1" id="9cT-ls-dQa">
|
||||
<rect key="frame" x="0.0" y="328" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="9cT-ls-dQa" id="57y-WO-Oe2">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="ViewDidLoad Example" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fKN-25-6hl">
|
||||
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="ViewDidLoad Example" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fKN-25-6hl">
|
||||
<rect key="frame" x="15" y="12" width="161" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Deprecated" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="vj2-67-hOL">
|
||||
<rect key="frame" x="500" y="12" width="85" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
|
|
@ -337,7 +368,7 @@
|
|||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="429" y="578"/>
|
||||
<point key="canvasLocation" x="420" y="742"/>
|
||||
</scene>
|
||||
<!--Configuration-->
|
||||
<scene sceneID="nFi-cp-YQl">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// DelegateAppearanceViewController.h
|
||||
// FSCalendar
|
||||
//
|
||||
// Created by Wenchao Ding on 10/2/15.
|
||||
// Copyright © 2015 wenchaoios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "FSCalendar.h"
|
||||
|
||||
@interface DelegateAppearanceViewController : UIViewController <FSCalendarDataSource,FSCalendarDelegate,FSCalendarDelegateAppearance>
|
||||
|
||||
@property (weak, nonatomic) FSCalendar *calendar;
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
//
|
||||
// DelegateAppearanceViewController.m
|
||||
// FSCalendar
|
||||
//
|
||||
// Created by Wenchao Ding on 10/2/15.
|
||||
// Copyright © 2015 wenchaoios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DelegateAppearanceViewController.h"
|
||||
#import "FSCalendarTestMacros.h"
|
||||
#import "NSDate+FSExtension.h"
|
||||
|
||||
#define kPink [UIColor colorWithRed:198/255.0 green:51/255.0 blue:42/255.0 alpha:1.0]
|
||||
|
||||
@implementation DelegateAppearanceViewController
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.title = @"FSCalendar";
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
view.backgroundColor = [UIColor colorWithRed:.95 green:.95 blue:.95 alpha:1.0];
|
||||
self.view = view;
|
||||
|
||||
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 300)];
|
||||
calendar.backgroundColor = [UIColor whiteColor];
|
||||
calendar.dataSource = self;
|
||||
calendar.delegate = self;
|
||||
calendar.allowsMultipleSelection = YES;
|
||||
[self.view addSubview:calendar];
|
||||
self.calendar = calendar;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
for (int i = 1; i < 28; i+=2) {
|
||||
[_calendar selectDate:[[NSDate date].fs_firstDayOfMonth fs_dateByAddingDays:i]];
|
||||
}
|
||||
|
||||
#if 0
|
||||
FSCalendarTestSelectDate
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance selectionColorForDate:(NSDate *)date
|
||||
{
|
||||
if (date.fs_day % 5 == 0) {
|
||||
return [UIColor purpleColor];
|
||||
}
|
||||
if (date.fs_day % 3 == 0) {
|
||||
return [UIColor cyanColor];
|
||||
}
|
||||
if (date.fs_day % 7 == 0) {
|
||||
return kPink;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance titleSelectionColorForDate:(NSDate *)date
|
||||
{
|
||||
if (date.fs_day % 5 == 0) {
|
||||
return [UIColor orangeColor];
|
||||
}
|
||||
if (date.fs_day % 3 == 0) {
|
||||
return [UIColor purpleColor];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -69,6 +69,7 @@
|
|||
EE89AF9E1B9162B90001B657 /* NSString+FSExtension.h in Headers */ = {isa = PBXBuildFile; fileRef = EE89AF9C1B9162B90001B657 /* NSString+FSExtension.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
EE89AF9F1B9162B90001B657 /* NSString+FSExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = EE89AF9D1B9162B90001B657 /* NSString+FSExtension.m */; };
|
||||
EE89AFA01B9162B90001B657 /* NSString+FSExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = EE89AF9D1B9162B90001B657 /* NSString+FSExtension.m */; };
|
||||
EE90434B1BBEC32800E50992 /* DelegateAppearanceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EE90434A1BBEC32800E50992 /* DelegateAppearanceViewController.m */; settings = {ASSET_TAGS = (); }; };
|
||||
EECA10F81BA9C0E400945B83 /* FullScreenExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EECA10F71BA9C0E400945B83 /* FullScreenExampleViewController.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
|
@ -178,6 +179,8 @@
|
|||
EE638CF51B8A1F550006DD1A /* FSCalendarTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSCalendarTests.m; sourceTree = "<group>"; };
|
||||
EE89AF9C1B9162B90001B657 /* NSString+FSExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+FSExtension.h"; sourceTree = "<group>"; };
|
||||
EE89AF9D1B9162B90001B657 /* NSString+FSExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+FSExtension.m"; sourceTree = "<group>"; };
|
||||
EE9043491BBEC32800E50992 /* DelegateAppearanceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DelegateAppearanceViewController.h; sourceTree = SOURCE_ROOT; };
|
||||
EE90434A1BBEC32800E50992 /* DelegateAppearanceViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DelegateAppearanceViewController.m; sourceTree = SOURCE_ROOT; };
|
||||
EECA10F61BA9C0E400945B83 /* FullScreenExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullScreenExampleViewController.h; sourceTree = SOURCE_ROOT; };
|
||||
EECA10F71BA9C0E400945B83 /* FullScreenExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FullScreenExampleViewController.m; sourceTree = SOURCE_ROOT; };
|
||||
EEF1EB571BBCBBC600F1B357 /* FSCalendarSelectDateTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarSelectDateTest.h; sourceTree = SOURCE_ROOT; };
|
||||
|
|
@ -280,6 +283,7 @@
|
|||
EE638CD01B89DBE90006DD1A /* AppDelegate.m */,
|
||||
EE638CD11B89DBE90006DD1A /* FSTableViewController.h */,
|
||||
EE638CD21B89DBE90006DD1A /* FSTableViewController.m */,
|
||||
EE9043481BBEC2D500E50992 /* DelegateAppearance Example */,
|
||||
EECA10F51BA9BF9B00945B83 /* Fullscreen Example */,
|
||||
30F5D8571B9FC48C00C1C201 /* MultipleSelection Example */,
|
||||
EE52AE151B91E65D00016662 /* FSCalendarScope Example */,
|
||||
|
|
@ -393,6 +397,15 @@
|
|||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EE9043481BBEC2D500E50992 /* DelegateAppearance Example */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EE9043491BBEC32800E50992 /* DelegateAppearanceViewController.h */,
|
||||
EE90434A1BBEC32800E50992 /* DelegateAppearanceViewController.m */,
|
||||
);
|
||||
name = "DelegateAppearance Example";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
EECA10F51BA9BF9B00945B83 /* Fullscreen Example */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -560,6 +573,7 @@
|
|||
EE638CB31B89DB450006DD1A /* libLunar.c in Sources */,
|
||||
EE638CBA1B89DB450006DD1A /* SSHolidayUK.m in Sources */,
|
||||
EE638CC61B89DB7D0006DD1A /* ViewDidLoadExampleViewController.m in Sources */,
|
||||
EE90434B1BBEC32800E50992 /* DelegateAppearanceViewController.m in Sources */,
|
||||
EE638CB91B89DB450006DD1A /* SSHolidayTW.m in Sources */,
|
||||
30B0BACF1B8D8E23004B9476 /* FSCalendar+IBExtension.m in Sources */,
|
||||
EE638CBE1B89DB450006DD1A /* SSLunarDateFormatter.m in Sources */,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
{
|
||||
[super viewDidLoad];
|
||||
// _calendar.scrollDirection = FSCalendarScrollDirectionVertical;
|
||||
_calendar.firstWeekday = 1;
|
||||
}
|
||||
|
||||
- (void)calendarCurrentScopeWillChange:(FSCalendar *)calendar animated:(BOOL)animated
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#import "ViewDidLoadExampleViewController.h"
|
||||
#import "MultipleSelectionViewController.h"
|
||||
#import "FullScreenExampleViewController.h"
|
||||
#import "DelegateAppearanceViewController.h"
|
||||
|
||||
@implementation FSTableViewController
|
||||
|
||||
|
|
@ -23,25 +24,28 @@
|
|||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.row == 0) {
|
||||
FullScreenExampleViewController *viewController = [[FullScreenExampleViewController alloc] init];
|
||||
DelegateAppearanceViewController *viewController = [[DelegateAppearanceViewController alloc] init];
|
||||
[self.navigationController pushViewController:viewController animated:YES];
|
||||
} else if (indexPath.row == 1) {
|
||||
MultipleSelectionViewController *viewController = [[MultipleSelectionViewController alloc] init];
|
||||
FullScreenExampleViewController *viewController = [[FullScreenExampleViewController alloc] init];
|
||||
[self.navigationController pushViewController:viewController animated:YES];
|
||||
} else if (indexPath.row == 2) {
|
||||
MultipleSelectionViewController *viewController = [[MultipleSelectionViewController alloc] init];
|
||||
[self.navigationController pushViewController:viewController animated:YES];
|
||||
} else if (indexPath.row == 3) {
|
||||
// FSCalendarScope Example
|
||||
return;
|
||||
|
||||
} else if (indexPath.row == 3) {
|
||||
} else if (indexPath.row == 4) {
|
||||
// Storyboard Example
|
||||
return;
|
||||
} else if (indexPath.row == 4) {
|
||||
} else if (indexPath.row == 5) {
|
||||
|
||||
// LoadView Example
|
||||
LoadViewExampleViewController *viewController = [[LoadViewExampleViewController alloc] init];
|
||||
[self.navigationController pushViewController:viewController animated:YES];
|
||||
|
||||
} else if (indexPath.row == 5) {
|
||||
} else if (indexPath.row == 6) {
|
||||
|
||||
// ViewDidLoad Example
|
||||
ViewDidLoadExampleViewController *viewController = [[ViewDidLoadExampleViewController alloc] init];
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
- (void)loadView
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
view.backgroundColor = [UIColor whiteColor];
|
||||
view.backgroundColor = [UIColor colorWithRed:.95 green:.95 blue:.95 alpha:1.0];
|
||||
self.view = view;
|
||||
|
||||
FSCalendar *calendar = [[FSCalendar alloc] initWithFrame:CGRectMake(0, 64, view.frame.size.width, 300)];
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
calendar.delegate = self;
|
||||
calendar.scrollDirection = FSCalendarScrollDirectionVertical;
|
||||
[calendar selectDate:[NSDate fs_dateWithYear:2015 month:2 day:1]];
|
||||
calendar.backgroundColor = [UIColor whiteColor];
|
||||
[view addSubview:calendar];
|
||||
self.calendar = calendar;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#import "FSCalendar.h"
|
||||
#import "NSDate+FSExtension.h"
|
||||
|
||||
@interface MultipleSelectionViewController : UIViewController <FSCalendarDataSource,FSCalendarDelegate,FSCalendarDelegateAppearance>
|
||||
@interface MultipleSelectionViewController : UIViewController <FSCalendarDataSource,FSCalendarDelegate>
|
||||
|
||||
@property (weak, nonatomic) FSCalendar *calendar;
|
||||
|
||||
|
|
|
|||
|
|
@ -83,20 +83,4 @@
|
|||
NSLog(@"selected dates is %@",selectedDates);
|
||||
}
|
||||
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance selectionColorForDate:(NSDate *)date
|
||||
{
|
||||
if (date.fs_day % 3 == 0) {
|
||||
return [UIColor yellowColor];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance titleSelectionColorForDate:(NSDate *)date
|
||||
{
|
||||
if (date.fs_day % 3 == 0) {
|
||||
return [UIColor blueColor];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
//- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
|
||||
//{
|
||||
// return date.fs_day == 3;
|
||||
// return date.fs_day % 5 == 0;
|
||||
//}
|
||||
|
||||
//- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = "FSCalendar"
|
||||
s.version = "1.4.1"
|
||||
s.version = "1.5.0"
|
||||
s.summary = "The fastest, most beautiful and most convenient calendar control, https://www.cocoacontrols.com/controls/fscalendar"
|
||||
|
||||
s.homepage = "https://github.com/WenchaoIOS/FSCalendar"
|
||||
|
|
|
|||
|
|
@ -73,7 +73,9 @@ typedef NS_ENUM(NSInteger, FSCalendarCellState) {
|
|||
|
||||
@optional
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance selectionColorForDate:(NSDate *)date;
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance titleDefaultColorForDate:(NSDate *)date;
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance titleSelectionColorForDate:(NSDate *)date;
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance subtitleDefaultColorForDate:(NSDate *)date;
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance subtitleSelectionColorForDate:(NSDate *)date;
|
||||
- (UIColor *)calendar:(FSCalendar *)calendar appearance:(FSCalendarAppearance *)appearance eventColorForDate:(NSDate *)date;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@
|
|||
- (NSDate *)maximumDateForCalendar;
|
||||
|
||||
- (UIColor *)preferedSelectionColorForDate:(NSDate *)date;
|
||||
- (UIColor *)preferedTitleDefaultColorForDate:(NSDate *)date;
|
||||
- (UIColor *)preferedTitleSelectionColorForDate:(NSDate *)date;
|
||||
- (UIColor *)preferedSubtitleDefaultColorForDate:(NSDate *)date;
|
||||
- (UIColor *)preferedSubtitleSelectionColorForDate:(NSDate *)date;
|
||||
- (UIColor *)preferedEventColorForDate:(NSDate *)date;
|
||||
|
||||
|
|
@ -421,8 +423,12 @@
|
|||
cell.dateIsToday = [cell.date fs_isEqualToDateForDay:_today];
|
||||
|
||||
cell.preferedSelectionColor = [self preferedSelectionColorForDate:cell.date];
|
||||
cell.preferedTitleDefaultColor = [self preferedTitleDefaultColorForDate:cell.date];
|
||||
cell.preferedTitleSelectionColor = [self preferedTitleSelectionColorForDate:cell.date];
|
||||
if (cell.subtitle) cell.preferedSubtitleSelectionColor = [self preferedSubtitleSelectionColorForDate:cell.date];
|
||||
if (cell.subtitle) {
|
||||
cell.preferedSubtitleDefaultColor = [self preferedSubtitleDefaultColorForDate:cell.date];
|
||||
cell.preferedSubtitleSelectionColor = [self preferedSubtitleSelectionColorForDate:cell.date];
|
||||
}
|
||||
if (cell.hasEvent) cell.preferedEventColor = [self preferedEventColorForDate:cell.date];
|
||||
|
||||
switch (_scope) {
|
||||
|
|
@ -526,12 +532,12 @@
|
|||
FSCalendarCell *cell = (FSCalendarCell *)[collectionView cellForItemAtIndexPath:indexPath];
|
||||
if (cell) {
|
||||
_daysContainer.clipsToBounds = NO;
|
||||
// [cell performDeselecting];
|
||||
cell.dateIsSelected = NO;
|
||||
[cell setNeedsLayout];
|
||||
[_selectedDates removeObject:cell.date];
|
||||
[self didDeselectDate:cell.date];
|
||||
}
|
||||
NSDate *selectedDate = self.selectedDate;
|
||||
[_selectedDates removeObject:selectedDate];
|
||||
[self didDeselectDate:selectedDate];
|
||||
}
|
||||
|
||||
- (BOOL)collectionView:(UICollectionView *)collectionView shouldDeselectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
|
|
@ -1283,7 +1289,7 @@
|
|||
}
|
||||
case FSCalendarScopeWeek: {
|
||||
section = [date fs_weeksFrom:_minimumDate.fs_firstDayOfWeek];
|
||||
item = [date fs_daysFrom:date.fs_firstDayOfWeek];
|
||||
item = ((date.fs_weekday - _firstWeekday) + 7) % 7;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
@ -1457,6 +1463,15 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (UIColor *)preferedTitleDefaultColorForDate:(NSDate *)date
|
||||
{
|
||||
if (self.delegateAppearance && [self.delegateAppearance respondsToSelector:@selector(calendar:appearance:titleDefaultColorForDate:)]) {
|
||||
UIColor *color = [self.delegateAppearance calendar:self appearance:self.appearance titleDefaultColorForDate:date];
|
||||
return color;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIColor *)preferedTitleSelectionColorForDate:(NSDate *)date
|
||||
{
|
||||
if (self.delegateAppearance && [self.delegateAppearance respondsToSelector:@selector(calendar:appearance:titleSelectionColorForDate:)]) {
|
||||
|
|
@ -1466,6 +1481,15 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (UIColor *)preferedSubtitleDefaultColorForDate:(NSDate *)date
|
||||
{
|
||||
if (self.delegateAppearance && [self.delegateAppearance respondsToSelector:@selector(calendar:appearance:subtitleDefaultColorForDate:)]) {
|
||||
UIColor *color = [self.delegateAppearance calendar:self appearance:self.appearance subtitleDefaultColorForDate:date];
|
||||
return color;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIColor *)preferedSubtitleSelectionColorForDate:(NSDate *)date
|
||||
{
|
||||
if (self.delegateAppearance && [self.delegateAppearance respondsToSelector:@selector(calendar:appearance:subtitleSelectionColorForDate:)]) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@
|
|||
@property (readonly, nonatomic) BOOL weekend;
|
||||
|
||||
@property (strong, nonatomic) UIColor *preferedSelectionColor;
|
||||
@property (strong, nonatomic) UIColor *preferedTitleDefaultColor;
|
||||
@property (strong, nonatomic) UIColor *preferedTitleSelectionColor;
|
||||
@property (strong, nonatomic) UIColor *preferedSubtitleDefaultColor;
|
||||
@property (strong, nonatomic) UIColor *preferedSubtitleSelectionColor;
|
||||
@property (strong, nonatomic) UIColor *preferedEventColor;
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@
|
|||
if (self.dateIsSelected || self.isSelected) {
|
||||
return self.preferedTitleSelectionColor ?: [self colorForCurrentStateInDictionary:_appearance.titleColors];
|
||||
}
|
||||
return [self colorForCurrentStateInDictionary:_appearance.titleColors];
|
||||
return self.preferedTitleDefaultColor ?: [self colorForCurrentStateInDictionary:_appearance.titleColors];
|
||||
}
|
||||
|
||||
- (UIColor *)colorForSubtitleLabel
|
||||
|
|
@ -233,7 +233,7 @@
|
|||
if (self.dateIsSelected || self.isSelected) {
|
||||
return self.preferedSubtitleSelectionColor ?: [self colorForCurrentStateInDictionary:_appearance.subtitleColors];
|
||||
}
|
||||
return [self colorForCurrentStateInDictionary:_appearance.subtitleColors];
|
||||
return self.preferedSubtitleDefaultColor ?: [self colorForCurrentStateInDictionary:_appearance.subtitleColors];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -102,9 +102,8 @@
|
|||
NSDateComponents *componentsToSubtract = [[NSDateComponents alloc] init];
|
||||
componentsToSubtract.day = - (weekdayComponents.weekday - calendar.firstWeekday);
|
||||
NSDate *beginningOfWeek = [calendar dateByAddingComponents:componentsToSubtract toDate:self options:0];
|
||||
NSDateComponents *components = [calendar components: (NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay)
|
||||
fromDate: beginningOfWeek];
|
||||
beginningOfWeek = [calendar dateFromComponents: components];
|
||||
NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:beginningOfWeek];
|
||||
beginningOfWeek = [calendar dateFromComponents:components];
|
||||
return beginningOfWeek;
|
||||
}
|
||||
|
||||
|
|
|
|||
2
LICENSE
2
LICENSE
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2015 = <f33chobits@gmail.com>
|
||||
Copyright (c) 2013-2015 FSCalendar (https://github.com/WenchaoIOS/FSCalendar)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
|||
|
|
@ -0,0 +1,294 @@
|
|||
# More usage
|
||||
|
||||
### If you want `FSCalendar` to scroll vertically
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scrollDirection = FSCalendarScrollDirectionVertical;
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scrollDirection = .Vertical
|
||||
```
|
||||
|
||||

|
||||
|
||||
### If you want `FSCalendar` to scroll horizontally (Default)
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scrollDirection = FSCalendarScrollDirectionHorizontal; // By default
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scrollDirection = .Horizontal
|
||||
```
|
||||
|
||||

|
||||
|
||||
### For week mode
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scope = FSCalendarScopeWeek;
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scope = .Week
|
||||
```
|
||||
|
||||
### For month mode
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scope = FSCalendarScopeMonth; // By default
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scope = .Month
|
||||
```
|
||||
|
||||

|
||||
|
||||
### To select more than one date
|
||||
|
||||
```objective-c
|
||||
_calendar.allowsMultipleSelection = YES;
|
||||
```
|
||||
|
||||

|
||||
|
||||
### If you want `FSCalendar` to use `Monday` as the first column (or any other weekday)
|
||||
|
||||
```objective-c
|
||||
_calendar.firstWeekday = 2;
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### The date format of header can be customized
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.headerDateFormat = @"MMM yy";
|
||||
```
|
||||
|
||||

|
||||
|
||||
### You can define the appearance
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.weekdayTextColor = [UIColor redColor];
|
||||
_calendar.appearance.headerTitleColor = [UIColor redColor];
|
||||
_calendar.appearance.eventColor = [UIColor greenColor];
|
||||
_calendar.appearance.selectionColor = [UIColor blueColor];
|
||||
_calendar.appearance.todayColor = [UIColor orangeColor];
|
||||
_calendar.appearance.todaySelectionColor = [UIColor blackColor];
|
||||
```
|
||||
|
||||

|
||||
|
||||
### The day shape doesn't have to be a circle
|
||||
|
||||
* Objective - c
|
||||
```objective-c
|
||||
_calendar.appearance.cellStyle = FSCalendarCellStyleRectangle;
|
||||
```
|
||||
|
||||
* Swift
|
||||
```swift
|
||||
calendar.appearance.cellStyle = .Rectangle
|
||||
```
|
||||
|
||||

|
||||
|
||||
### `FSCalendar` can show subtitle for each day
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
|
||||
{
|
||||
return yourSubtitle;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDataSource
|
||||
func calendar(calendar: FSCalendar!, subtitleForDate date: NSDate!) -> String! {
|
||||
return yourSubtitle
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
<br/>
|
||||

|
||||
|
||||
### And event dot for some days
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
|
||||
{
|
||||
return shouldShowEventDot;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDataSource
|
||||
func calendar(calendar: FSCalendar!, hasEventForDate date: NSDate!) -> Bool {
|
||||
return shouldShowEventDot
|
||||
}
|
||||
```
|
||||
|
||||
### Or image for some days
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
|
||||
{
|
||||
return anyImage;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDataSource
|
||||
func calendar(calendar: FSCalendar!, imageForDate date: NSDate!) -> UIImage! {
|
||||
return anyImage
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
#### There are left and right boundaries
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
|
||||
{
|
||||
return yourMinimumDate;
|
||||
}
|
||||
|
||||
- (NSDate *)maximumDateForCalendar:(FSCalendar *)calendar
|
||||
{
|
||||
return yourMaximumDate;
|
||||
}
|
||||
```
|
||||
|
||||
### You can do something when a date is selected
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDelegate
|
||||
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
|
||||
{
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDelegate
|
||||
func calendar(calendar: FSCalendar!, didSelectDate date: NSDate!) {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### You can prevent it from being selected
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDelegate
|
||||
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
|
||||
{
|
||||
if ([dateShouldNotBeSelected]) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
func calendar(calendar: FSCalendar!, shouldSelectDate date: NSDate!) -> Bool {
|
||||
if dateShouldNotBeSelected {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### You will get notified when `FSCalendar` changes the month
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar
|
||||
{
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
func calendarCurrentMonthDidChange(calendar: FSCalendar!) {
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
### `FSCalendar` can be used on `iPad`.
|
||||

|
||||
|
||||
### <a id="roll_with_interface_builder"></a> Roll with Interface Builder
|
||||
|
||||

|
||||
|
||||
|
||||
* `fakeSubtitles` and `fakedSelectedDay` is only used for preview in Interface Builder
|
||||
|
||||
## Known issues
|
||||
|
||||
* What if I don't need the `today` circle?
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.todayColor = [UIColor clearColor];
|
||||
_calendar.appearance.titleTodayColor = _calendar.appearance.titleDefaultColor;
|
||||
_calendar.appearance.subtitleTodayColor = _calendar.appearance.subtitleDefaultColor;
|
||||
```
|
||||
|
||||
* Can we hide this?
|
||||

|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.headerMinimumDissolvedAlpha = 0.0;
|
||||
```
|
||||
327
README.md
327
README.md
|
|
@ -5,10 +5,7 @@
|
|||
[](http://cocoadocs.org/docsets/FSCalendar)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||

|
||||
|
||||
# Installation
|
||||
|
||||
|
|
@ -81,322 +78,18 @@ view.addSubview(calendar)
|
|||
self.calendar = calendar
|
||||
```
|
||||
|
||||
## More usage
|
||||
## More Usage
|
||||
* To view more usage, download the zip file and read the example.
|
||||
* Or your could refer to [this document](https://github.com/WenchaoIOS/FSCalendar/MOREUSAGE.md)
|
||||
|
||||
### If you want `FSCalendar` to scroll vertically
|
||||
# If you like this repo
|
||||
* Star this repo.
|
||||
* Send your calendar screenshot to #2, or the itunes url of the app.
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scrollDirection = FSCalendarScrollDirectionVertical;
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scrollDirection = .Vertical
|
||||
```
|
||||
|
||||

|
||||
|
||||
### If you want `FSCalendar` to scroll horizontally (Default)
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scrollDirection = FSCalendarScrollDirectionHorizontal; // By default
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scrollDirection = .Horizontal
|
||||
```
|
||||
|
||||

|
||||
|
||||
### For week mode
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scope = FSCalendarScopeWeek;
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scope = .Week
|
||||
```
|
||||
|
||||
### For month mode
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
_calendar.scope = FSCalendarScopeMonth; // By default
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
calendar.scope = .Month
|
||||
```
|
||||
|
||||

|
||||
|
||||
### To select more than one date
|
||||
|
||||
```objective-c
|
||||
_calendar.allowsMultipleSelection = YES;
|
||||
```
|
||||
|
||||

|
||||
|
||||
### If you want `FSCalendar` to use `Monday` as the first column (or any other weekday)
|
||||
|
||||
```objective-c
|
||||
_calendar.firstWeekday = 2;
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### The date format of header can be customized
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.headerDateFormat = @"MMM yy";
|
||||
```
|
||||
|
||||

|
||||
|
||||
### You can define the appearance
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.weekdayTextColor = [UIColor redColor];
|
||||
_calendar.appearance.headerTitleColor = [UIColor redColor];
|
||||
_calendar.appearance.eventColor = [UIColor greenColor];
|
||||
_calendar.appearance.selectionColor = [UIColor blueColor];
|
||||
_calendar.appearance.todayColor = [UIColor orangeColor];
|
||||
_calendar.appearance.todaySelectionColor = [UIColor blackColor];
|
||||
```
|
||||
|
||||

|
||||
|
||||
### The day shape doesn't have to be a circle
|
||||
|
||||
* Objective - c
|
||||
```objective-c
|
||||
_calendar.appearance.cellStyle = FSCalendarCellStyleRectangle;
|
||||
```
|
||||
|
||||
* Swift
|
||||
```swift
|
||||
calendar.appearance.cellStyle = .Rectangle
|
||||
```
|
||||
|
||||

|
||||
|
||||
### `FSCalendar` can show subtitle for each day
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
|
||||
{
|
||||
return yourSubtitle;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDataSource
|
||||
func calendar(calendar: FSCalendar!, subtitleForDate date: NSDate!) -> String! {
|
||||
return yourSubtitle
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
<br/>
|
||||

|
||||
|
||||
### And event dot for some days
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (BOOL)calendar:(FSCalendar *)calendar hasEventForDate:(NSDate *)date
|
||||
{
|
||||
return shouldShowEventDot;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDataSource
|
||||
func calendar(calendar: FSCalendar!, hasEventForDate date: NSDate!) -> Bool {
|
||||
return shouldShowEventDot
|
||||
}
|
||||
```
|
||||
|
||||
### Or image for some days
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (UIImage *)calendar:(FSCalendar *)calendar imageForDate:(NSDate *)date
|
||||
{
|
||||
return anyImage;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDataSource
|
||||
func calendar(calendar: FSCalendar!, imageForDate date: NSDate!) -> UIImage! {
|
||||
return anyImage
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
#### There are left and right boundaries
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDataSource
|
||||
- (NSDate *)minimumDateForCalendar:(FSCalendar *)calendar
|
||||
{
|
||||
return yourMinimumDate;
|
||||
}
|
||||
|
||||
- (NSDate *)maximumDateForCalendar:(FSCalendar *)calendar
|
||||
{
|
||||
return yourMaximumDate;
|
||||
}
|
||||
```
|
||||
|
||||
### You can do something when a date is selected
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDelegate
|
||||
- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
|
||||
{
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
// FSCalendarDelegate
|
||||
func calendar(calendar: FSCalendar!, didSelectDate date: NSDate!) {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### You can prevent it from being selected
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
// FSCalendarDelegate
|
||||
- (BOOL)calendar:(FSCalendar *)calendar shouldSelectDate:(NSDate *)date
|
||||
{
|
||||
if ([dateShouldNotBeSelected]) {
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
func calendar(calendar: FSCalendar!, shouldSelectDate date: NSDate!) -> Bool {
|
||||
if dateShouldNotBeSelected {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### You will get notified when `FSCalendar` changes the month
|
||||
|
||||
* Objective - c
|
||||
|
||||
```objective-c
|
||||
- (void)calendarCurrentMonthDidChange:(FSCalendar *)calendar
|
||||
{
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
* Swift
|
||||
|
||||
```swift
|
||||
func calendarCurrentMonthDidChange(calendar: FSCalendar!) {
|
||||
// Do something
|
||||
}
|
||||
```
|
||||
|
||||
### `FSCalendar` can be used on `iPad`.
|
||||

|
||||
|
||||
### <a id="roll_with_interface_builder"></a> Roll with Interface Builder
|
||||
|
||||

|
||||
|
||||
|
||||
* `fakeSubtitles` and `fakedSelectedDay` is only used for preview in Interface Builder
|
||||
|
||||
## Known issues
|
||||
* The title size changed as we change frame size of FSCalendar: Automatically adjusting font size based on frame size is default behavior of FSCalendadr, to disable it:
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.autoAdjustTitleSize = NO;
|
||||
_calendar.appearance.titleFont = otherTitleFont;
|
||||
_calendar.appearance.subtitleFont = otherSubtitleFont;
|
||||
```
|
||||
|
||||
`titleFont` and `subtitleFont` would not take any effect if `autoAdjustTitleSize` value is `YES`
|
||||
|
||||
* What if I don't need the `today` circle?
|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.todayColor = [UIColor clearColor];
|
||||
_calendar.appearance.titleTodayColor = _calendar.appearance.titleDefaultColor;
|
||||
_calendar.appearance.subtitleTodayColor = _calendar.appearance.subtitleDefaultColor;
|
||||
```
|
||||
|
||||
* Can we hide this?
|
||||

|
||||
|
||||
```objective-c
|
||||
_calendar.appearance.headerMinimumDissolvedAlpha = 0.0;
|
||||
```
|
||||
# Contact me
|
||||
* Email: `f33chobits@gmail.com`
|
||||
* Skype: `wenchao.ding`
|
||||
|
||||
# License
|
||||
|
||||
FSCalendar is available under the MIT license. See the LICENSE file for more info.
|
||||
|
||||
# Support
|
||||
* If FSCalendar cannot meet your requirment, tell me in issues or send your pull requests
|
||||
* If you like this control and use it in your app, submit your app's link address [here](https://www.cocoacontrols.com/controls/fscalendar).It would be a great support.
|
||||
|
||||
# Contact
|
||||
* email: `f33chobits@gmail.com`
|
||||
* skype: `wenchao.ding`
|
||||
|
||||
# Donate
|
||||
* Paypal - f33chobits@gmail.com
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue