From 288b71b67128c0d480ff9f4b869948e63b2041c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Sun, 5 Jun 2016 23:51:02 -0700 Subject: [ios] Simplified MBXAnnotationView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eliminated the center view in favor of applying a background color and border to the annotation view’s layer. --- platform/ios/app/MBXAnnotationView.h | 3 --- platform/ios/app/MBXAnnotationView.m | 20 ++++---------------- platform/ios/app/MBXViewController.m | 10 ++++------ 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/platform/ios/app/MBXAnnotationView.h b/platform/ios/app/MBXAnnotationView.h index 78dfe17699..5337ffae57 100644 --- a/platform/ios/app/MBXAnnotationView.h +++ b/platform/ios/app/MBXAnnotationView.h @@ -1,7 +1,4 @@ #import @interface MBXAnnotationView : MGLAnnotationView - -@property (nonatomic) UIColor *centerColor; - @end diff --git a/platform/ios/app/MBXAnnotationView.m b/platform/ios/app/MBXAnnotationView.m index 82af15314a..61f9b1c047 100644 --- a/platform/ios/app/MBXAnnotationView.m +++ b/platform/ios/app/MBXAnnotationView.m @@ -1,28 +1,16 @@ #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; - } + + self.layer.borderColor = [UIColor blueColor].CGColor; + self.layer.borderWidth = 1; + self.layer.cornerRadius = 2; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index ed312e87a2..3fdd88fad8 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -587,22 +587,20 @@ static NSString * const MBXViewControllerAnnotationViewReuseIdentifer = @"MBXVie { annotationView = [[MBXAnnotationView alloc] initWithReuseIdentifier:MBXViewControllerAnnotationViewReuseIdentifer]; annotationView.frame = CGRectMake(0, 0, 10, 10); - annotationView.centerColor = [UIColor whiteColor]; - + annotationView.backgroundColor = [UIColor whiteColor]; + // uncomment to make the annotation view draggable // also note that having two long press gesture recognizers on overlapping views (`self.view` & `annotationView`) will cause weird behaviour // comment out the pin dropping functionality in the handleLongPress: method in this class to make draggable annotation views play nice annotationView.draggable = YES; - - + // uncomment to force annotation view to maintain a constant size when the map is tilted // by default, annotation views will shrink and grow as the move towards and away from the // horizon. Relatedly, annotations backed by GL sprites ONLY scale with viewing distance currently. // annotationView.scalesWithViewingDistance = NO; - } else { // orange indicates that the annotation view was reused - annotationView.centerColor = [UIColor orangeColor]; + annotationView.backgroundColor = [UIColor orangeColor]; } return annotationView; } -- cgit v1.2.1