Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accessibility for TKCalendarMonthView

First attempts at making Month View Accessible.
  • Loading branch information...
commit 65b0cd231a64a0e46bcf698cf4b0d8fe6a681ac3 1 parent cedd121
@mikevpark mikevpark authored
Showing with 31 additions and 1 deletion.
  1. +31 −1 src/TapkuLibrary/TKCalendarMonthView.m
View
32 src/TapkuLibrary/TKCalendarMonthView.m
@@ -166,6 +166,11 @@ @interface TKCalendarMonthTiles (private)
@implementation TKCalendarMonthTiles
@synthesize monthDate;
+//The container itself is not accessible
+- (BOOL)isAccessibilityElement
+{
+ return NO;
+}
+ (NSArray*) rangeOfDatesInMonthGrid:(NSDate*)date startOnSunday:(BOOL)sunday{
@@ -303,7 +308,12 @@ - (id) initWithMonth:(NSDate*)date marks:(NSArray*)markArray startDayOnSunday:(B
[self.selectedImageView addSubview:self.currentDay];
[self.selectedImageView addSubview:self.dot];
self.multipleTouchEnabled = NO;
-
+
+ //Set Accessibility
+ self.selectedImageView.isAccessibilityElement = YES;
+ self.selectedImageView.accessibilityTraits = UIAccessibilityTraitButton;
+ self.selectedImageView.accessibilityLabel = [NSString stringWithFormat:@"Day %@, %@", self.currentDay.text, self.dot ? @"Activities" : @"No Activities"];
+
return self;
}
@@ -717,6 +727,24 @@ - (id) initWithSundayAsFirst:(BOOL)s{
for(NSString *s in ar){
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(46 * i, 29, 46, 15)];
[self addSubview:label];
+
+ //Added Accessibility Labels
+ if ([s isEqualToString:@"Sun"]) {
+ label.accessibilityLabel = @"Sunday";
+ } else if ([s isEqualToString:@"Mon"]) {
+ label.accessibilityLabel = @"Monday";
+ } else if ([s isEqualToString:@"Tue"]) {
+ label.accessibilityLabel = @"Tuesday";
+ } else if ([s isEqualToString:@"Wed"]) {
+ label.accessibilityLabel = @"Wednesday";
+ } else if ([s isEqualToString:@"Thu"]) {
+ label.accessibilityLabel = @"Thursday";
+ } else if ([s isEqualToString:@"Fri"]) {
+ label.accessibilityLabel = @"Friday";
+ } else if ([s isEqualToString:@"Sat"]) {
+ label.accessibilityLabel = @"Saturday";
+ }
+
label.text = s;
label.textAlignment = UITextAlignmentCenter;
label.shadowColor = [UIColor whiteColor];
@@ -973,6 +1001,7 @@ - (UIButton *) leftArrow{
if(leftArrow==nil){
leftArrow = [UIButton buttonWithType:UIButtonTypeCustom];
leftArrow.tag = 0;
+ leftArrow.accessibilityLabel = @"Previous Month";
[leftArrow addTarget:self action:@selector(changeMonth:) forControlEvents:UIControlEventTouchUpInside];
[leftArrow setImage:[UIImage imageNamedTK:@"TapkuLibrary.bundle/Images/calendar/Month Calendar Left Arrow"] forState:0];
leftArrow.frame = CGRectMake(0, 0, 48, 38);
@@ -983,6 +1012,7 @@ - (UIButton *) rightArrow{
if(rightArrow==nil){
rightArrow = [UIButton buttonWithType:UIButtonTypeCustom];
rightArrow.tag = 1;
+ rightArrow.accessibilityLabel = @"Next Month";
[rightArrow addTarget:self action:@selector(changeMonth:) forControlEvents:UIControlEventTouchUpInside];
rightArrow.frame = CGRectMake(320-45, 0, 48, 38);
[rightArrow setImage:[UIImage imageNamedTK:@"TapkuLibrary.bundle/Images/calendar/Month Calendar Right Arrow"] forState:0];
Please sign in to comment.
Something went wrong with that request. Please try again.