Glyph images won't change colors
up vote
1
down vote
favorite
Problem: I have three glyphs from the same site (icons8.com) and when I try to set them to the same color, only 1 works properly.
In-Depth:
So I am attempting to get some glyphs to change colors. Some work, and some don't.
Here you can see that the glyphs are setting properly to a "yellow" tint
But then when I go to a different view that calls the same color procedure, it doesn't work. The glyphs stay black on the coffee and beer sign (the two that do not work), but the soccer ball sets properly. Reminder, all are being set to yellow.
This is the code I am using the set the glyph color in the cell within the normal cellForRowAt
.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the view that I am using the create the markers.
class EventMarkerView: MKMarkerAnnotationView {
override var annotation: MKAnnotation? {
willSet {
guard let eventAnnotation = newValue as? EventAnnotation else { return }
canShowCallout = true
calloutOffset = CGPoint(x: -5, y: 5)
rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
markerTintColor = eventAnnotation.markerTintColor
glyphTintColor = eventAnnotation.glyphTintColor
//glyphText = String(event.discipline.first!)
if let imageName = eventAnnotation.imageName {
glyphImage = UIImage(named: imageName)
} else {
glyphImage = nil
}
let detailLabel = UILabel()
detailLabel.numberOfLines = 3
detailLabel.font = detailLabel.font.withSize(12)
detailLabel.text = eventAnnotation.subtitle
detailCalloutAccessoryView = detailLabel
}
}
}
I will also attach the different sets of glyphs I am using.
"Beer". doesn't work .
"Soccer ball outline". Does work .
"Cafe". doesn't work .
swift uicolor glyph
add a comment |
up vote
1
down vote
favorite
Problem: I have three glyphs from the same site (icons8.com) and when I try to set them to the same color, only 1 works properly.
In-Depth:
So I am attempting to get some glyphs to change colors. Some work, and some don't.
Here you can see that the glyphs are setting properly to a "yellow" tint
But then when I go to a different view that calls the same color procedure, it doesn't work. The glyphs stay black on the coffee and beer sign (the two that do not work), but the soccer ball sets properly. Reminder, all are being set to yellow.
This is the code I am using the set the glyph color in the cell within the normal cellForRowAt
.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the view that I am using the create the markers.
class EventMarkerView: MKMarkerAnnotationView {
override var annotation: MKAnnotation? {
willSet {
guard let eventAnnotation = newValue as? EventAnnotation else { return }
canShowCallout = true
calloutOffset = CGPoint(x: -5, y: 5)
rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
markerTintColor = eventAnnotation.markerTintColor
glyphTintColor = eventAnnotation.glyphTintColor
//glyphText = String(event.discipline.first!)
if let imageName = eventAnnotation.imageName {
glyphImage = UIImage(named: imageName)
} else {
glyphImage = nil
}
let detailLabel = UILabel()
detailLabel.numberOfLines = 3
detailLabel.font = detailLabel.font.withSize(12)
detailLabel.text = eventAnnotation.subtitle
detailCalloutAccessoryView = detailLabel
}
}
}
I will also attach the different sets of glyphs I am using.
"Beer". doesn't work .
"Soccer ball outline". Does work .
"Cafe". doesn't work .
swift uicolor glyph
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Problem: I have three glyphs from the same site (icons8.com) and when I try to set them to the same color, only 1 works properly.
In-Depth:
So I am attempting to get some glyphs to change colors. Some work, and some don't.
Here you can see that the glyphs are setting properly to a "yellow" tint
But then when I go to a different view that calls the same color procedure, it doesn't work. The glyphs stay black on the coffee and beer sign (the two that do not work), but the soccer ball sets properly. Reminder, all are being set to yellow.
This is the code I am using the set the glyph color in the cell within the normal cellForRowAt
.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the view that I am using the create the markers.
class EventMarkerView: MKMarkerAnnotationView {
override var annotation: MKAnnotation? {
willSet {
guard let eventAnnotation = newValue as? EventAnnotation else { return }
canShowCallout = true
calloutOffset = CGPoint(x: -5, y: 5)
rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
markerTintColor = eventAnnotation.markerTintColor
glyphTintColor = eventAnnotation.glyphTintColor
//glyphText = String(event.discipline.first!)
if let imageName = eventAnnotation.imageName {
glyphImage = UIImage(named: imageName)
} else {
glyphImage = nil
}
let detailLabel = UILabel()
detailLabel.numberOfLines = 3
detailLabel.font = detailLabel.font.withSize(12)
detailLabel.text = eventAnnotation.subtitle
detailCalloutAccessoryView = detailLabel
}
}
}
I will also attach the different sets of glyphs I am using.
"Beer". doesn't work .
"Soccer ball outline". Does work .
"Cafe". doesn't work .
swift uicolor glyph
Problem: I have three glyphs from the same site (icons8.com) and when I try to set them to the same color, only 1 works properly.
In-Depth:
So I am attempting to get some glyphs to change colors. Some work, and some don't.
Here you can see that the glyphs are setting properly to a "yellow" tint
But then when I go to a different view that calls the same color procedure, it doesn't work. The glyphs stay black on the coffee and beer sign (the two that do not work), but the soccer ball sets properly. Reminder, all are being set to yellow.
This is the code I am using the set the glyph color in the cell within the normal cellForRowAt
.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the view that I am using the create the markers.
class EventMarkerView: MKMarkerAnnotationView {
override var annotation: MKAnnotation? {
willSet {
guard let eventAnnotation = newValue as? EventAnnotation else { return }
canShowCallout = true
calloutOffset = CGPoint(x: -5, y: 5)
rightCalloutAccessoryView = UIButton(type: .detailDisclosure)
markerTintColor = eventAnnotation.markerTintColor
glyphTintColor = eventAnnotation.glyphTintColor
//glyphText = String(event.discipline.first!)
if let imageName = eventAnnotation.imageName {
glyphImage = UIImage(named: imageName)
} else {
glyphImage = nil
}
let detailLabel = UILabel()
detailLabel.numberOfLines = 3
detailLabel.font = detailLabel.font.withSize(12)
detailLabel.text = eventAnnotation.subtitle
detailCalloutAccessoryView = detailLabel
}
}
}
I will also attach the different sets of glyphs I am using.
"Beer". doesn't work .
"Soccer ball outline". Does work .
"Cafe". doesn't work .
swift uicolor glyph
swift uicolor glyph
asked Nov 7 at 4:59
thalacker
387
387
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I found the answer eventually. I had to force the image (note the second line) to always use my template.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")?.withRenderingMode(.alwaysTemplate)
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the apple documentation for .withRenderingMode.
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I found the answer eventually. I had to force the image (note the second line) to always use my template.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")?.withRenderingMode(.alwaysTemplate)
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the apple documentation for .withRenderingMode.
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
add a comment |
up vote
0
down vote
accepted
I found the answer eventually. I had to force the image (note the second line) to always use my template.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")?.withRenderingMode(.alwaysTemplate)
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the apple documentation for .withRenderingMode.
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I found the answer eventually. I had to force the image (note the second line) to always use my template.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")?.withRenderingMode(.alwaysTemplate)
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the apple documentation for .withRenderingMode.
I found the answer eventually. I had to force the image (note the second line) to always use my template.
cell.iconView.backgroundColor = eventAnnotation.markerTintColor
cell.iconImageView.image = UIImage(named: eventAnnotation.imageName ?? "")?.withRenderingMode(.alwaysTemplate)
cell.iconImageView.tintColor = eventAnnotation.glyphTintColor
Here is the apple documentation for .withRenderingMode.
answered Nov 10 at 17:40
thalacker
387
387
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
add a comment |
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
You can also set this property in the xcassets folder of your project. Select the image group (the one that contains all resolutions) and use the menu on the right.
– EmilioPelaez
Nov 10 at 17:56
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183784%2fglyph-images-wont-change-colors%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown