Annotation views now serve as their own accessibility elements. The developer’s own subclass of MGLAnnotationView can customize the view’s accessibility frame and/or path to more accurately reflect the visual hit target.
53 lines
1.3 KiB
Objective-C
53 lines
1.3 KiB
Objective-C
#import "MGLAnnotationContainerView.h"
|
|
#import "MGLAnnotationView.h"
|
|
|
|
@interface MGLAnnotationContainerView ()
|
|
|
|
@property (nonatomic) NS_MUTABLE_ARRAY_OF(MGLAnnotationView *) *annotationViews;
|
|
|
|
@end
|
|
|
|
@implementation MGLAnnotationContainerView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self)
|
|
{
|
|
_annotationViews = [NSMutableArray array];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
+ (instancetype)annotationContainerViewWithAnnotationContainerView:(nonnull MGLAnnotationContainerView *)annotationContainerView
|
|
{
|
|
MGLAnnotationContainerView *newAnnotationContainerView = [[MGLAnnotationContainerView alloc] initWithFrame:annotationContainerView.frame];
|
|
[newAnnotationContainerView addSubviews:annotationContainerView.subviews];
|
|
return newAnnotationContainerView;
|
|
}
|
|
|
|
- (void)addSubviews:(NS_ARRAY_OF(MGLAnnotationView *) *)subviews
|
|
{
|
|
for (MGLAnnotationView *view in subviews)
|
|
{
|
|
[self addSubview:view];
|
|
[self.annotationViews addObject:view];
|
|
}
|
|
}
|
|
|
|
#pragma mark UIAccessibility methods
|
|
|
|
- (UIAccessibilityTraits)accessibilityTraits {
|
|
return UIAccessibilityTraitAdjustable;
|
|
}
|
|
|
|
- (void)accessibilityIncrement {
|
|
[self.superview.superview accessibilityIncrement];
|
|
}
|
|
|
|
- (void)accessibilityDecrement {
|
|
[self.superview.superview accessibilityDecrement];
|
|
}
|
|
|
|
@end
|