Skip to content

Commit

Permalink
Merge pull request #53 from jeremiescheer/master
Browse files Browse the repository at this point in the history
Add calendar title
  • Loading branch information
hons82 committed Oct 26, 2015
2 parents 4d29de7 + 57b496f commit 05a546c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions THCalendarDatePicker/THDatePickerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,14 @@

- (void)setDateRangeFrom:(NSDate *)fromDate toDate:(NSDate *)toDate;

/*! Set calendar title
* \param dateTitle calendar title
*/
- (void)setDateTitle:(NSString*)dateTitle;

/**
* Calendar date title
*/
@property (strong, nonatomic) NSString* dateTitle;

@end
14 changes: 14 additions & 0 deletions THCalendarDatePicker/THDatePickerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ @interface THDatePickerViewController () {
@property (weak, nonatomic) IBOutlet UIButton *closeBtn;
@property (weak, nonatomic) IBOutlet UIButton *clearBtn;
@property (weak, nonatomic) IBOutlet UIButton *okBtn;
@property (unsafe_unretained, nonatomic) IBOutlet UILabel *titleLabel;
@property (strong, nonatomic) IBOutlet UIView *calendarDaysView;
@property (weak, nonatomic) IBOutlet UIView *weekdaysView;

Expand Down Expand Up @@ -150,6 +151,9 @@ - (void)viewDidLoad {
selector:@selector(semiModalDidHide:)
name:kSemiModalDidHideNotification
object:nil];

self.titleLabel.hidden = YES;

[self configureButtonAppearances];
if(_allowClearDate)
[self showClearButton];
Expand Down Expand Up @@ -255,6 +259,16 @@ - (void)redraw {
formatter.locale=[NSLocale currentLocale];
NSString *monthName = [formatter stringFromDate:self.firstOfCurrentMonth];
self.monthLabel.text = monthName;

if (self.dateTitle != nil)
{
if (_allowClearDate == NO)
{
self.titleLabel.text = self.dateTitle;
self.titleLabel.hidden = NO;
}
}

[self redrawDays];
}

Expand Down
10 changes: 10 additions & 0 deletions THCalendarDatePicker/THDatePickerViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<outlet property="okBtn" destination="8" id="67"/>
<outlet property="prevMonthBtn" destination="FBs-ue-0FL" id="r1e-o5-dpK"/>
<outlet property="prevYearBtn" destination="9" id="eap-a6-4dN"/>
<outlet property="titleLabel" destination="wv9-lp-lWG" id="6HO-dW-hLB"/>
<outlet property="toolbarBackgroundView" destination="g6a-bo-Ej7" id="qL0-W5-WAM"/>
<outlet property="view" destination="5" id="48"/>
<outlet property="weekdaysView" destination="68" id="69"/>
Expand Down Expand Up @@ -155,9 +156,18 @@ Month</string>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wv9-lp-lWG">
<rect key="frame" x="143" y="11" width="34" height="21"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="wv9-lp-lWG" firstAttribute="top" secondItem="s0u-MY-tL4" secondAttribute="top" constant="11" id="BsT-EG-lC5"/>
<constraint firstAttribute="width" constant="320" id="G5S-5U-Jba"/>
<constraint firstItem="wv9-lp-lWG" firstAttribute="centerX" secondItem="s0u-MY-tL4" secondAttribute="centerX" id="q0h-ME-a8Z"/>
</constraints>
</view>
</subviews>
Expand Down

0 comments on commit 05a546c

Please sign in to comment.