Skip to content

Commit

Permalink
Respect some accessibility options
Browse files Browse the repository at this point in the history
  • Loading branch information
CooperRS committed Mar 9, 2015
1 parent 9941544 commit 9e64871
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,22 @@ typedef void (^RMDateCancelBlock)(RMDateSelectionViewController *vc);

/**
* Used to enable or disable motion effects. Default value is NO.
*
* @warning This property always returns YES, if motion is reduced via accessibilty options.
*/
@property (assign, nonatomic) BOOL disableMotionEffects;

/**
* Used to enable or disable bouncing effects when sliding in the date selection view. Default value is NO.
*
* @warning This property always returns YES, if motion is reduced via accessibilty options.
*/
@property (assign, nonatomic) BOOL disableBouncingWhenShowing;

/**
* Used to enable or disable blurring the date selection view. Default value is NO.
*
* @warning This property always returns NO if either UIBlurEffect, UIVibrancyEffect or UIVisualEffectView is not available on your system at runtime.
* @warning This property always returns YES if either UIBlurEffect, UIVibrancyEffect or UIVisualEffectView is not available on your system at runtime or transparency is reduced via accessibility options.
*/
@property (assign, nonatomic) BOOL disableBlurEffects;

Expand Down
25 changes: 22 additions & 3 deletions RMDateSelectionViewController/RMDateSelectionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ @interface RMDateSelectionViewController () <UIPopoverControllerDelegate>
@implementation RMDateSelectionViewController

@synthesize selectedBackgroundColor = _selectedBackgroundColor;
@synthesize disableMotionEffects = _disableMotionEffects;

#pragma mark - Class
+ (instancetype)dateSelectionController {
Expand Down Expand Up @@ -706,11 +707,21 @@ - (UIImage *)imageWithColor:(UIColor *)color {

#pragma mark - Properties
- (BOOL)disableBlurEffects {
if(NSClassFromString(@"UIBlurEffect") && NSClassFromString(@"UIVibrancyEffect") && NSClassFromString(@"UIVisualEffectView") && !_disableBlurEffects) {
return NO;
if(!NSClassFromString(@"UIBlurEffect") || !NSClassFromString(@"UIVibrancyEffect") || !NSClassFromString(@"UIVisualEffectView")) {
return YES;
} else if(UIAccessibilityIsReduceTransparencyEnabled()) {
return YES;
}

return YES;
return _disableBlurEffects;
}

- (BOOL)disableMotionEffects {
if(UIAccessibilityIsReduceMotionEnabled()) {
return YES;
}

return _disableMotionEffects;
}

- (void)setDisableMotionEffects:(BOOL)newDisableMotionEffects {
Expand All @@ -727,6 +738,14 @@ - (void)setDisableMotionEffects:(BOOL)newDisableMotionEffects {
}
}

- (BOOL)disableBouncingWhenShowing {
if(UIAccessibilityIsReduceMotionEnabled()) {
return YES;
}

return _disableBouncingWhenShowing;
}

- (UIMotionEffectGroup *)motionEffectGroup {
if(!_motionEffectGroup) {
UIInterpolatingMotionEffect *verticalMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];
Expand Down

0 comments on commit 9e64871

Please sign in to comment.