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
enter image description here



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.
enter image description here



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 .










share|improve this question


























    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
    enter image description here



    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.
    enter image description here



    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 .










    share|improve this question
























      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
      enter image description here



      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.
      enter image description here



      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 .










      share|improve this question













      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
      enter image description here



      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.
      enter image description here



      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 7 at 4:59









      thalacker

      387




      387
























          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.






          share|improve this answer





















          • 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











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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

























          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.






          share|improve this answer





















          • 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















          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.






          share|improve this answer





















          • 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













          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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


















          • 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


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python