Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tintColor of UIImageView doesn't work with storyboard,but work with code

Xcode 9 beta 6,iOS 11

I downloaded a Instagram logo which was a .png file,and I created a UIButton and UIImageView in the Main.storyboard.The logo image was set as follows:

Set mode

And I set the TintColor of the UIButton and the UIImageView is white,but when I run the project, the color of the image for UIImageView is still black,while white for UIButton.

imageView setting:

enter image description here

black color

Why it is black for imageView and white for button with the same setting of the image? Thanks.

Additional remarks:

When I used code to add the subview imageView,it worked well.Really werid! enter image description here

like image 367
Ringo Avatar asked Sep 07 '17 02:09

Ringo


2 Answers

I set global tintColor in AppDelegate.

I was not getting proper tint color on iOS 13 Xcode 11 in dark mode. However, same image tint color appeared correct when set fora bar button.

I resolved it by setting Render As property of the image as Template Image in images.xcassets. I neither had to remove UIImageView in storyboard nor add again or adding user defined property.

like image 129
ashishn Avatar answered Sep 18 '22 11:09

ashishn


Problem still exists in Xcode 9.4.1

Setting desired color for tintColor in User Defined Runtime Attributes help me to fix this problem:

enter image description here

like image 28
Vitalii Gozhenko Avatar answered Sep 17 '22 11:09

Vitalii Gozhenko