CLWeeklyCalendarView.m 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. //
  2. // CLWeeklyCalendarView.m
  3. // Deputy
  4. //
  5. // Created by Caesar on 30/10/2014.
  6. // Copyright (c) 2014 Caesar Li. All rights reserved.
  7. //
  8. #import "CLWeeklyCalendarView.h"
  9. #import "DailyCalendarView.h"
  10. #import "DayTitleLabel.h"
  11. #import "NSDate+CL.h"
  12. #import "UIColor+CL.h"
  13. #import "NSDictionary+CL.h"
  14. #import "UIImage+CL.h"
  15. #define WEEKLY_VIEW_COUNT 7
  16. #define DAY_TITLE_VIEW_HEIGHT 20.f
  17. #define DAY_TITLE_FONT_SIZE 12.f
  18. #define GREEN_DAY_TITLE_FONT_SIZE 13.f
  19. #define DATE_TITLE_MARGIN_TOP 22.f
  20. #define DATE_VIEW_MARGIN 3.f
  21. #define DATE_VIEW_HEIGHT 28.f
  22. #define DATE_LABEL_MARGIN_LEFT 9.f
  23. #define DATE_LABEL_INFO_WIDTH 160.f
  24. #define DATE_LABEL_INFO_HEIGHT 40.f
  25. #define WEATHER_ICON_WIDTH 20
  26. #define WEATHER_ICON_HEIGHT 20
  27. #define WEATHER_ICON_LEFT 90
  28. #define WEATHER_ICON_MARGIN_TOP 9
  29. //Attribute Keys
  30. NSString *const CLCalendarWeekStartDay = @"CLCalendarWeekStartDay";
  31. NSString *const CLCalendarDayTitleTextColor = @"CLCalendarDayTitleTextColor";
  32. NSString *const CLCalendarSelectedDatePrintFormat = @"CLCalendarSelectedDatePrintFormat";
  33. NSString *const CLCalendarSelectedDatePrintColor = @"CLCalendarSelectedDatePrintColor";
  34. NSString *const CLCalendarSelectedDatePrintFontSize = @"CLCalendarSelectedDatePrintFontSize";
  35. NSString *const CLCalendarBackgroundImageColor = @"CLCalendarBackgroundImageColor";
  36. //Default Values
  37. static NSInteger const CLCalendarWeekStartDayDefault = 1;
  38. static NSInteger const CLCalendarDayTitleTextColorDefault = 0xC2E8FF;
  39. static NSString* const CLCalendarSelectedDatePrintFormatDefault = @"yyyy-MM-dd ,EEE";
  40. static float const CLCalendarSelectedDatePrintFontSizeDefault = 13.f;
  41. @interface CLWeeklyCalendarView()<DailyCalendarViewDelegate, UIGestureRecognizerDelegate, CAAnimationDelegate>
  42. @property (nonatomic, strong) UIView *dailySubViewContainer;
  43. @property (nonatomic, strong) UIView *dayTitleSubViewContainer;
  44. @property (nonatomic, strong) UIImageView *backgroundImageView;
  45. @property (nonatomic, strong) UIView *dailyInfoSubViewContainer;
  46. @property (nonatomic, strong) UIImageView *weatherIcon;
  47. @property (nonatomic, strong) UILabel *dateInfoLabel;
  48. @property (nonatomic, strong) NSDate *startDate;
  49. @property (nonatomic, strong) NSDate *endDate;
  50. @property (nonatomic, strong) NSDictionary *arrDailyWeather;
  51. @property (nonatomic, strong) NSNumber *weekStartConfig;
  52. @property (nonatomic, strong) UIColor *dayTitleTextColor;
  53. @property (nonatomic, strong) NSString *selectedDatePrintFormat;
  54. @property (nonatomic, strong) UIColor *selectedDatePrintColor;
  55. @property (nonatomic) float selectedDatePrintFontSize;
  56. @property (nonatomic, strong) UIColor *backgroundImageColor;
  57. @end
  58. @implementation CLWeeklyCalendarView
  59. - (id)initWithFrame:(CGRect)frame
  60. {
  61. self = [super initWithFrame:frame];
  62. if (self) {
  63. // Initialization code
  64. [self addSubview:self.backgroundImageView];
  65. self.arrDailyWeather = @{};
  66. }
  67. return self;
  68. }
  69. -(void)setDelegate:(id<CLWeeklyCalendarViewDelegate>)delegate
  70. {
  71. _delegate = delegate;
  72. [self applyCustomDefaults];
  73. }
  74. -(void)setGreenDayArray:(NSArray *)greenDayArray {
  75. _greenDayArray = greenDayArray;
  76. [self delegateSwipeAnimation: NO blnToday:NO selectedDate:nil];
  77. [self delegateSwipeAnimation: YES blnToday:NO selectedDate:nil];
  78. }
  79. -(void)applyCustomDefaults
  80. {
  81. NSDictionary *attributes;
  82. if ([self.delegate respondsToSelector:@selector(CLCalendarBehaviorAttributes)]) {
  83. attributes = [self.delegate CLCalendarBehaviorAttributes];
  84. }
  85. self.weekStartConfig = attributes[CLCalendarWeekStartDay] ? attributes[CLCalendarWeekStartDay] : [NSNumber numberWithInt:CLCalendarWeekStartDayDefault];
  86. self.dayTitleTextColor = attributes[CLCalendarDayTitleTextColor]? attributes[CLCalendarDayTitleTextColor]:[UIColor colorWithHex:CLCalendarDayTitleTextColorDefault];
  87. self.selectedDatePrintFormat = attributes[CLCalendarSelectedDatePrintFormat]? attributes[CLCalendarSelectedDatePrintFormat] : CLCalendarSelectedDatePrintFormatDefault;
  88. self.selectedDatePrintColor = attributes[CLCalendarSelectedDatePrintColor]? attributes[CLCalendarSelectedDatePrintColor] : [UIColor whiteColor];
  89. self.selectedDatePrintFontSize = attributes[CLCalendarSelectedDatePrintFontSize]? [attributes[CLCalendarSelectedDatePrintFontSize] floatValue] : CLCalendarSelectedDatePrintFontSizeDefault;
  90. //NSLog(@"%@ %f", attributes[CLCalendarBackgroundImageColor], self.selectedDatePrintFontSize);
  91. self.backgroundImageColor = attributes[CLCalendarBackgroundImageColor];
  92. [self setNeedsDisplay];
  93. }
  94. -(UIView *)dailyInfoSubViewContainer
  95. {
  96. if(!_dailyInfoSubViewContainer){
  97. _dailyInfoSubViewContainer = [[UIView alloc] initWithFrame:CGRectMake(0, DATE_TITLE_MARGIN_TOP+DAY_TITLE_VIEW_HEIGHT + DATE_VIEW_HEIGHT + DATE_VIEW_MARGIN * 2, self.bounds.size.width, DATE_LABEL_INFO_HEIGHT)];
  98. _dailyInfoSubViewContainer.userInteractionEnabled = YES;
  99. [_dailyInfoSubViewContainer addSubview:self.weatherIcon];
  100. [_dailyInfoSubViewContainer addSubview:self.dateInfoLabel];
  101. UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dailyInfoViewDidClick:)];
  102. [_dailyInfoSubViewContainer addGestureRecognizer:singleFingerTap];
  103. }
  104. return _dailyInfoSubViewContainer;
  105. }
  106. -(UIImageView *)weatherIcon
  107. {
  108. if(!_weatherIcon){
  109. _weatherIcon = [[UIImageView alloc] initWithFrame:CGRectMake(WEATHER_ICON_LEFT, WEATHER_ICON_MARGIN_TOP, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT)];
  110. }
  111. return _weatherIcon;
  112. }
  113. -(UILabel *)dateInfoLabel
  114. {
  115. if(!_dateInfoLabel){
  116. _dateInfoLabel = [[UILabel alloc] initWithFrame:CGRectMake(WEATHER_ICON_LEFT+WEATHER_ICON_WIDTH+DATE_LABEL_MARGIN_LEFT, 0, DATE_LABEL_INFO_WIDTH, DATE_LABEL_INFO_HEIGHT)];
  117. _dateInfoLabel.textAlignment = NSTextAlignmentCenter;
  118. _dateInfoLabel.userInteractionEnabled = YES;
  119. }
  120. _dateInfoLabel.font = [UIFont systemFontOfSize: self.selectedDatePrintFontSize];
  121. _dateInfoLabel.textColor = self.selectedDatePrintColor;
  122. return _dateInfoLabel;
  123. }
  124. -(UIView *)dayTitleSubViewContainer
  125. {
  126. if(!_dayTitleSubViewContainer){
  127. _dayTitleSubViewContainer = [[UIImageView alloc] initWithFrame:CGRectMake(0, DATE_TITLE_MARGIN_TOP, self.bounds.size.width, DAY_TITLE_VIEW_HEIGHT)];
  128. _dayTitleSubViewContainer.backgroundColor = [UIColor clearColor];
  129. _dayTitleSubViewContainer.userInteractionEnabled = YES;
  130. }
  131. return _dayTitleSubViewContainer;
  132. }
  133. -(UIView *)dailySubViewContainer
  134. {
  135. if(!_dailySubViewContainer){
  136. _dailySubViewContainer = [[UIImageView alloc] initWithFrame:CGRectMake(0, DATE_TITLE_MARGIN_TOP+DAY_TITLE_VIEW_HEIGHT+DATE_VIEW_MARGIN, self.bounds.size.width, DATE_VIEW_HEIGHT)];
  137. _dailySubViewContainer.backgroundColor = [UIColor clearColor];
  138. _dailySubViewContainer.userInteractionEnabled = YES;
  139. }
  140. return _dailySubViewContainer;
  141. }
  142. -(UIImageView *)backgroundImageView
  143. {
  144. //设置背景图 然后添加控件
  145. if(!_backgroundImageView){
  146. _backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
  147. _backgroundImageView.userInteractionEnabled = YES;
  148. //周
  149. [_backgroundImageView addSubview:self.dayTitleSubViewContainer];
  150. //日期
  151. [_backgroundImageView addSubview:self.dailySubViewContainer];
  152. //danson 这个是显示当前选中的日期 可以去掉
  153. [_backgroundImageView addSubview:self.dailyInfoSubViewContainer];
  154. //Apply swipe gesture
  155. UISwipeGestureRecognizer *recognizerRight;
  156. recognizerRight.delegate=self;
  157. recognizerRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRight:)];
  158. [recognizerRight setDirection:UISwipeGestureRecognizerDirectionRight];
  159. [_backgroundImageView addGestureRecognizer:recognizerRight];
  160. UISwipeGestureRecognizer *recognizerLeft;
  161. recognizerLeft.delegate=self;
  162. recognizerLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeft:)];
  163. [recognizerLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
  164. [_backgroundImageView addGestureRecognizer:recognizerLeft];
  165. }
  166. _backgroundImageView.backgroundColor = self.backgroundImageColor? self.backgroundImageColor : [UIColor colorWithPatternImage:[UIImage calendarBackgroundImage:self.bounds.size.height]];;
  167. return _backgroundImageView;
  168. }
  169. -(void)initDailyViews
  170. {
  171. CGFloat dailyWidth = self.bounds.size.width/WEEKLY_VIEW_COUNT;
  172. NSDate *today = [NSDate new];
  173. NSDate *dtWeekStart = [today getWeekStartDate:self.weekStartConfig.integerValue];
  174. self.startDate = dtWeekStart;
  175. for (UIView *v in [self.dailySubViewContainer subviews]){
  176. [v removeFromSuperview];
  177. }
  178. for (UIView *v in [self.dayTitleSubViewContainer subviews]){
  179. [v removeFromSuperview];
  180. }
  181. for(int i = 0; i < WEEKLY_VIEW_COUNT; i++){
  182. NSDate *dt = [dtWeekStart addDays:i];
  183. [self dayTitleViewForDate: dt inFrame: CGRectMake(dailyWidth*i, 0, dailyWidth, DAY_TITLE_VIEW_HEIGHT)];
  184. [self dailyViewForDate:dt inFrame: CGRectMake(dailyWidth*i, 0, dailyWidth, DATE_VIEW_HEIGHT) ];
  185. self.endDate = dt;
  186. }
  187. [self dailyCalendarViewDidSelect:[NSDate new]];
  188. }
  189. -(UILabel *)dayTitleViewForDate: (NSDate *)date inFrame: (CGRect)frame
  190. {
  191. DayTitleLabel *dayTitleLabel = [[DayTitleLabel alloc] initWithFrame:frame];
  192. dayTitleLabel.backgroundColor = [UIColor clearColor];
  193. dayTitleLabel.textColor = self.dayTitleTextColor;
  194. dayTitleLabel.textAlignment = NSTextAlignmentCenter;
  195. dayTitleLabel.font = [UIFont systemFontOfSize:DAY_TITLE_FONT_SIZE];
  196. dayTitleLabel.text = [[date getDayOfWeekShortString] uppercaseString];
  197. dayTitleLabel.date = date;
  198. dayTitleLabel.userInteractionEnabled = YES;
  199. UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dayTitleViewDidClick:)];
  200. [dayTitleLabel addGestureRecognizer:singleFingerTap];
  201. [self.dayTitleSubViewContainer addSubview:dayTitleLabel];
  202. return dayTitleLabel;
  203. }
  204. -(DailyCalendarView *)dailyViewForDate: (NSDate *)date inFrame: (CGRect)frame
  205. {
  206. DailyCalendarView *view = [[DailyCalendarView alloc] initWithFrame:frame];
  207. view.date = date;
  208. view.backgroundColor = [UIColor clearColor];
  209. view.delegate = self;
  210. [self.dailySubViewContainer addSubview:view];
  211. return view;
  212. }
  213. // Only override drawRect: if you perform custom drawing.
  214. // An empty implementation adversely affects performance during animation.
  215. - (void)drawRect:(CGRect)rect
  216. {
  217. // Drawing code
  218. [self initDailyViews];
  219. }
  220. -(void)markDateSelected:(NSDate *)date
  221. {
  222. for (DailyCalendarView *v in [self.dailySubViewContainer subviews]){
  223. [v markSelected:([v.date isSameDateWith:date])];
  224. }
  225. self.selectedDate = date;
  226. NSDateFormatter *dayFormatter = [[NSDateFormatter alloc] init];
  227. [dayFormatter setDateFormat:self.selectedDatePrintFormat];
  228. NSString *strDate = [dayFormatter stringFromDate:date];
  229. if([date isDateToday]){
  230. //danson
  231. strDate = [NSString stringWithFormat:@"今天, %@", strDate];
  232. }
  233. [self adjustDailyInfoLabelAndWeatherIcon : NO];
  234. self.dateInfoLabel.text = strDate;
  235. }
  236. -(void)dailyInfoViewDidClick: (UIGestureRecognizer *)tap
  237. {
  238. //Click to jump back to today
  239. [self redrawToDate:[NSDate new]];
  240. }
  241. -(void)dayTitleViewDidClick: (UIGestureRecognizer *)tap
  242. {
  243. [self redrawToDate:((DayTitleLabel *)tap.view).date];
  244. }
  245. -(void)redrawToDate:(NSDate *)dt
  246. {
  247. if(![dt isWithinDate:self.startDate toDate:self.endDate]){
  248. BOOL swipeRight = ([dt compare:self.startDate] == NSOrderedAscending);
  249. [self delegateSwipeAnimation:swipeRight blnToday:[dt isDateToday] selectedDate:dt];
  250. }
  251. [self dailyCalendarViewDidSelect:dt];
  252. }
  253. -(void)redrawCalenderData
  254. {
  255. [self redrawToDate:self.selectedDate];
  256. }
  257. -(void)adjustDailyInfoLabelAndWeatherIcon: (BOOL)blnShowWeatherIcon
  258. {
  259. self.dateInfoLabel.textAlignment = (blnShowWeatherIcon)?NSTextAlignmentLeft:NSTextAlignmentCenter;
  260. if(blnShowWeatherIcon){
  261. if([self.selectedDate isDateToday]){
  262. self.weatherIcon.frame = CGRectMake(WEATHER_ICON_LEFT-20, WEATHER_ICON_MARGIN_TOP, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT);
  263. self.dateInfoLabel.frame = CGRectMake(WEATHER_ICON_LEFT+WEATHER_ICON_WIDTH+DATE_LABEL_MARGIN_LEFT-20, 0, DATE_LABEL_INFO_WIDTH, DATE_LABEL_INFO_HEIGHT);
  264. }else{
  265. self.weatherIcon.frame = CGRectMake(WEATHER_ICON_LEFT, WEATHER_ICON_MARGIN_TOP, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT);
  266. self.dateInfoLabel.frame = CGRectMake(WEATHER_ICON_LEFT+WEATHER_ICON_WIDTH+DATE_LABEL_MARGIN_LEFT, 0, DATE_LABEL_INFO_WIDTH, DATE_LABEL_INFO_HEIGHT);
  267. }
  268. }else{
  269. self.dateInfoLabel.frame = CGRectMake( (self.bounds.size.width - DATE_LABEL_INFO_WIDTH)/2, 0, DATE_LABEL_INFO_WIDTH, DATE_LABEL_INFO_HEIGHT);
  270. }
  271. self.weatherIcon.hidden = !blnShowWeatherIcon;
  272. }
  273. #pragma swipe
  274. -(void)swipeLeft: (UISwipeGestureRecognizer *)swipe
  275. {
  276. [self delegateSwipeAnimation: NO blnToday:NO selectedDate:nil];
  277. }
  278. -(void)swipeRight: (UISwipeGestureRecognizer *)swipe
  279. {
  280. [self delegateSwipeAnimation: YES blnToday:NO selectedDate:nil];
  281. }
  282. -(void)delegateSwipeAnimation: (BOOL)blnSwipeRight blnToday: (BOOL)blnToday selectedDate:(NSDate *)selectedDate
  283. {
  284. //这次不用做限制
  285. //danson 判断是否超出15天 设定为能查看三周 这样的话一定能看到未来15天
  286. if (_isLimitDate) {
  287. //封装成一个外边可以判断的 那是最好的了 等有空搞一个 或者下次要不同功能的时候 到时候直接在外边设定值来设置这里
  288. NSInteger judgeStep = ([[NSNumber numberWithBool:blnSwipeRight] boolValue])? -1 : 1;
  289. NSDate *wdStart;
  290. if(blnToday){
  291. wdStart = [[NSDate new] getWeekStartDate:self.weekStartConfig.integerValue];
  292. }else{
  293. wdStart = (selectedDate)? [selectedDate getWeekStartDate:self.weekStartConfig.integerValue]:[self.startDate addDays:judgeStep*7];
  294. }
  295. NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
  296. [gregorian setFirstWeekday:2];
  297. // NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  298. // [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  299. NSDate *fromDate;
  300. NSDate *toDate;
  301. [gregorian rangeOfUnit:NSCalendarUnitDay startDate:&fromDate interval:nil forDate:wdStart];
  302. [gregorian rangeOfUnit:NSCalendarUnitDay startDate:&toDate interval:nil forDate:[NSDate date]];
  303. NSDateComponents *dayComponents = [gregorian components:NSCalendarUnitDay fromDate:fromDate toDate:toDate options:0];
  304. //NSLog(@"dayComponents.day---->%d",(int)dayComponents.day);
  305. if (dayComponents.day > 14 || dayComponents.day <-14) {
  306. return;
  307. }
  308. }
  309. //如果在范围内 再改变值 做滑动处理
  310. CATransition *animation = [CATransition animation];
  311. [animation setDelegate:self];
  312. [animation setType:kCATransitionPush];
  313. [animation setSubtype:(blnSwipeRight)?kCATransitionFromLeft:kCATransitionFromRight];
  314. [animation setDuration:0.50];
  315. [animation setTimingFunction:
  316. [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
  317. [self.dailySubViewContainer.layer addAnimation:animation forKey:kCATransition];
  318. NSMutableDictionary *data = @{@"blnSwipeRight": [NSNumber numberWithBool:blnSwipeRight], @"blnToday":[NSNumber numberWithBool:blnToday]}.mutableCopy;
  319. if(selectedDate){
  320. [data setObject:selectedDate forKey:@"selectedDate"];
  321. }
  322. [self performSelector:@selector(renderSwipeDates:) withObject:data afterDelay:0.05f];
  323. }
  324. -(void)renderSwipeDates: (NSDictionary*)param
  325. {
  326. int step = ([[param objectForKey:@"blnSwipeRight"] boolValue])? -1 : 1;
  327. BOOL blnToday = [[param objectForKey:@"blnToday"] boolValue];
  328. NSDate *selectedDate = [param objectForKeyWithNil:@"selectedDate"];
  329. CGFloat dailyWidth = self.bounds.size.width/WEEKLY_VIEW_COUNT;
  330. NSDate *dtStart;
  331. if(blnToday){
  332. dtStart = [[NSDate new] getWeekStartDate:self.weekStartConfig.integerValue];
  333. }else{
  334. dtStart = (selectedDate)? [selectedDate getWeekStartDate:self.weekStartConfig.integerValue]:[self.startDate addDays:step*7];
  335. }
  336. self.startDate = dtStart;
  337. for (UIView *v in [self.dailySubViewContainer subviews]){
  338. [v removeFromSuperview];
  339. }
  340. for(int i = 0; i < WEEKLY_VIEW_COUNT; i++){
  341. NSDate *dt = [dtStart addDays:i];
  342. //设置显示选中的天(圆白块)
  343. DailyCalendarView* view = [self dailyViewForDate:dt inFrame: CGRectMake(dailyWidth*i, 0, dailyWidth, DATE_VIEW_HEIGHT) ];
  344. [view markSelected:([view.date isSameDateWith:self.selectedDate])];
  345. DayTitleLabel *titleLabel = [[self.dayTitleSubViewContainer subviews] objectAtIndex:i];
  346. titleLabel.date = dt;
  347. if ([_greenDayArray isKindOfClass:[NSArray class]]) {
  348. NSDateFormatter *greenFormatter = [[NSDateFormatter alloc] init];
  349. [greenFormatter setDateFormat:@"yyyy-MM-dd"];
  350. NSString *selectDateString = [greenFormatter stringFromDate:dt];
  351. if ([_greenDayArray containsObject:selectDateString]) {
  352. //表明该天可预约
  353. titleLabel.textColor = [UIColor whiteColor];
  354. titleLabel.font = [UIFont systemFontOfSize:GREEN_DAY_TITLE_FONT_SIZE];
  355. }else {
  356. titleLabel.textColor = [UIColor grayColor];//self.dayTitleTextColor
  357. titleLabel.font = [UIFont systemFontOfSize:DAY_TITLE_FONT_SIZE];
  358. }
  359. }else {
  360. titleLabel.textColor = self.dayTitleTextColor;
  361. titleLabel.font = [UIFont systemFontOfSize:DAY_TITLE_FONT_SIZE];
  362. }
  363. self.endDate = dt;
  364. }
  365. }
  366. -(void)updateWeatherIconByKey:(NSString *)key
  367. {
  368. if(!key){
  369. [self adjustDailyInfoLabelAndWeatherIcon:NO];
  370. return;
  371. }
  372. self.weatherIcon.image = [UIImage imageNamed:key];
  373. [self adjustDailyInfoLabelAndWeatherIcon:YES];
  374. }
  375. #pragma DeputyDailyCalendarViewDelegate
  376. -(void)dailyCalendarViewDidSelect:(NSDate *)date
  377. {
  378. [self markDateSelected:date];
  379. [self.delegate dailyCalendarViewDidSelect:date];
  380. }
  381. @end
  382. // 版权属于原作者
  383. // http://code4app.com (cn) http://code4app.net (en)
  384. // 发布代码于最专业的源码分享网站: Code4App.com