Skip to content

Commit

Permalink
Added a BOOL, setImagesAsTemplate, which allows for the image set to …
Browse files Browse the repository at this point in the history
…the imageView and headingImageView to be set as is instead of with the UIImageRenderingModeAlwaysTemplate Rendering Mode. Defaults to YES as to not change anything for those who would update to this commit and still want the Rendering Mode defaulting to Template. Fixes issue TransitApp#19 on SVPulsingAnnotationView.
  • Loading branch information
tysonkerridge committed Apr 13, 2017
1 parent 7ed05e3 commit 4c9160d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions SVPulsingAnnotationView/SVPulsingAnnotationView.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
@property (nonatomic, strong) UIImage *image; // default is nil
@property (nonatomic, strong) UIImage *headingImage; // default is nil
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, assign) BOOL setImagesAsTemplate; // default is YES

@property (nonatomic, readwrite) float outerDotAlpha; // default is 1
@property (nonatomic, readwrite) float pulseScaleFactor; // default is 5.3
Expand Down
5 changes: 3 additions & 2 deletions SVPulsingAnnotationView/SVPulsingAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ - (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString
self.annotationColor = [UIColor colorWithRed:0.000 green:0.478 blue:1.000 alpha:1];
self.outerColor = [UIColor whiteColor];
self.outerDotAlpha = 1;
self.setImagesAsTemplate = YES;

self.willMoveToSuperviewAnimationBlock = ^(SVPulsingAnnotationView *annotationView, UIView *superview) {
CAKeyframeAnimation *bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
Expand Down Expand Up @@ -151,7 +152,7 @@ - (void)setImage:(UIImage *)image {
CGFloat imageWidth = ceil(image.size.width);
CGFloat imageHeight = ceil(image.size.height);

self.imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.imageView.image = self.setImagesAsTemplate ? [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] : image;
self.imageView.frame = CGRectMake(floor((self.bounds.size.width - imageWidth) * 0.5),
floor((self.bounds.size.height - imageHeight) * 0.5),
imageWidth,
Expand All @@ -169,7 +170,7 @@ - (void)setHeadingImage:(UIImage *)image {
CGFloat imageWidth = ceil(image.size.width);
CGFloat imageHeight = ceil(image.size.height);

self.headingImageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.headingImageView.image = self.setImagesAsTemplate ? [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] : image;
self.headingImageView.frame = CGRectMake(floor((self.bounds.size.width - imageWidth) * 0.5),
floor((self.bounds.size.height - imageHeight) * 0.5),
imageWidth,
Expand Down

0 comments on commit 4c9160d

Please sign in to comment.