Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix property override super class. #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions SVPulsingAnnotationView/SVPulsingAnnotationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
@property (nonatomic, strong) UIColor *annotationColor; // default is same as MKUserLocationView
@property (nonatomic, strong) UIColor *outerColor; // default is white
@property (nonatomic, strong) UIColor *pulseColor; // default is same as annotationColor
@property (nonatomic, strong) UIImage *image; // default is nil
@property (nonatomic, strong) UIImage *headingImage; // default is nil
@property (nonatomic, strong) UIImageView *imageView;

@property (nonatomic, readwrite) float outerDotAlpha; // default is 1
@property (nonatomic, readwrite) float pulseScaleFactor; // default is 5.3
Expand Down
43 changes: 4 additions & 39 deletions SVPulsingAnnotationView/SVPulsingAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ @interface SVPulsingAnnotationView ()

@implementation SVPulsingAnnotationView

@synthesize annotation = _annotation;
@synthesize image = _image;

+ (NSMutableDictionary*)cachedRingImages {
static NSMutableDictionary *cachedRingLayers = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{ cachedRingLayers = [NSMutableDictionary new]; });
return cachedRingLayers;
}

- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
if(self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
self.layer.anchorPoint = CGPointMake(0.5, 0.5);
Expand Down Expand Up @@ -72,11 +62,6 @@ - (void)rebuildLayers {

_pulseAnimationGroup = nil;

if(!self.image) {
[_imageView removeFromSuperview];
_imageView = nil;
}

if (self.headingImage) {
[self addSubview:self.headingImageView];
}
Expand All @@ -87,14 +72,13 @@ - (void)rebuildLayers {

[self.layer addSublayer:self.colorHaloLayer];
[self.layer addSublayer:self.outerDotLayer];

if(self.image)
[self addSubview:self.imageView];
else

if(!self.image)
[self.layer addSublayer:self.colorDotLayer];
}

- (void)willMoveToSuperview:(UIView *)superview {
[super willMoveToSuperview:superview];
if(superview)
[self rebuildLayers];

Expand Down Expand Up @@ -122,7 +106,6 @@ - (void)setAnnotationColor:(UIColor *)annotationColor {
}

_annotationColor = annotationColor;
_imageView.tintColor = annotationColor;
_headingImageView.tintColor = annotationColor;

if(self.superview)
Expand All @@ -144,21 +127,11 @@ - (void)setPulseAnimationDuration:(NSTimeInterval)pulseAnimationDuration {
}

- (void)setImage:(UIImage *)image {
_image = image;
[super setImage:image];

if (self.superview) {
[self rebuildLayers];
}

CGFloat imageWidth = ceil(image.size.width);
CGFloat imageHeight = ceil(image.size.height);

self.imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.imageView.frame = CGRectMake(floor((self.bounds.size.width - imageWidth) * 0.5),
floor((self.bounds.size.height - imageHeight) * 0.5),
imageWidth,
imageHeight);
self.imageView.tintColor = self.annotationColor;
}

- (void)setHeadingImage:(UIImage *)image {
Expand Down Expand Up @@ -219,14 +192,6 @@ - (CAAnimationGroup*)pulseAnimationGroup {

#pragma mark - Graphics

- (UIImageView *)imageView {
if(!_imageView) {
_imageView = [[UIImageView alloc] initWithFrame:self.bounds];
_imageView.contentMode = UIViewContentModeTopLeft;
}
return _imageView;
}

- (UIImageView *)headingImageView {
if (!_headingImageView) {
_headingImageView = [[UIImageView alloc] initWithFrame:self.bounds];
Expand Down