J.Paravicini
J.Paravicini

Reputation: 892

Swift - Image color resets when Alert is displayed

So in my iOS app I have a menu designed like this:

enter image description here

The Images are created with the following code:

cell.imageCell?.image = menuItems[indexPath.row].image
    cell.imageCell.image = cell.imageCell.image?.withRenderingMode(.alwaysTemplate)
    cell.imageCell.tintColor = MenuTableViewController.fontColor
    cell.imageCell.backgroundColor = UIColor.clear

This code is placed in the tableview cellForRowAt function. Now all the different viewcontrollers(HomeViewController, InfoViewController etc...) have no access at all to the menu controller and thus are not able to change the color of the image and nowhere else am I changing the color of these images. Now when I press one of the tabs that don't use any Alerts or modal views like home or info, the images stay perfectly fine, however when I press on Weather or excursions which download a json file with URLSession dataTask and display an alert telling to please wait, the images turn grey like the following:

enter image description here

I'm not sure how this is even possible that one viewcontroller can change another viewcontrollers subviews. Thanks in advance -Jorge

Upvotes: 4

Views: 1627

Answers (2)

pronebird
pronebird

Reputation: 12230

Perhaps what you see is a dimmed presentation of your icons. Don't use image templates or set tintAdjustmentMode to normal to stop fading icons. Usually that happens if you display alert or modal controller.

Upvotes: 17

Lirik
Lirik

Reputation: 3187

It looks like its the default UITableViewCell click style. Try to set the style to none, as answered here: How can I disable the UITableView selection highlighting?

Swift:

cell.selectionStyle = UITableViewCellSelectionStyle.none

Upvotes: 1

Related Questions