summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-06-05 23:51:02 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-07-02 21:00:48 -0700
commit288b71b67128c0d480ff9f4b869948e63b2041c4 (patch)
tree98a8a7a0143a132721c03a97409428f4319862b8
parentbb2f627b1287483749487e405931d3cbe2c5363e (diff)
downloadqtlocation-mapboxgl-288b71b67128c0d480ff9f4b869948e63b2041c4.tar.gz
[ios] Simplified MBXAnnotationView
Eliminated the center view in favor of applying a background color and border to the annotation view’s layer.
-rw-r--r--platform/ios/app/MBXAnnotationView.h3
-rw-r--r--platform/ios/app/MBXAnnotationView.m20
-rw-r--r--platform/ios/app/MBXViewController.m10
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 <Mapbox/Mapbox.h>
@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;
}