Add a container view to hold annotations. This gets around a performance issue with `UIView:addSubview:` where adding views is N^2. It helps annotation views avoid cutting into callout views when the annotation views are transformed to be "flat".
29 lines
686 B
Objective-C
29 lines
686 B
Objective-C
#import "MBXAnnotationView.h"
|
|
|
|
@interface MBXAnnotationView ()
|
|
|
|
@property (nonatomic) UIView *centerView;
|
|
|
|
@end
|
|
|
|
@implementation MBXAnnotationView
|
|
|
|
- (void)layoutSubviews {
|
|
[super layoutSubviews];
|
|
if (!self.centerView) {
|
|
self.backgroundColor = [UIColor blueColor];
|
|
self.centerView = [[UIView alloc] initWithFrame:CGRectInset(self.bounds, 1.0, 1.0)];
|
|
self.centerView.backgroundColor = self.centerColor;
|
|
[self addSubview:self.centerView];
|
|
}
|
|
}
|
|
|
|
- (void)setCenterColor:(UIColor *)centerColor {
|
|
if (![_centerColor isEqual:centerColor]) {
|
|
_centerColor = centerColor;
|
|
self.centerView.backgroundColor = centerColor;
|
|
}
|
|
}
|
|
|
|
@end
|