Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add calendar title #53

Merged
merged 1 commit into from Oct 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions THCalendarDatePicker/THDatePickerViewController.h
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
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
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