removing white background in UIImageView - uiimageview

in my app there is an option to add image. when i'm adding an image and even if i don't add any image, there is always a white background. how can i get rid of it? (all my images are transparent (png))
Thanks.

set the view's background color to clear color on which you are adding the image.
for example:
imgView.backgroundColor=[UIColor clearColor];

Related

Why does my NSBox draw a background? (boxType = .primary)

I realized that suddenly (without me touching the corresponding code) my NSBox has a double visualization. It is as if the Box has a background color and draws its normal rounded frame inside. I added a small screenshot. The parent control is white, the NSBox is gray with the title "Inputs" (unchanged titlePosition). Under the title is the normal box, adding a 2nd shade of gray.
I did not change any of the usual suspects, especially not boxType which is still set to .primary.
I did work on the Dark Mode (Dark Aqua) but cannot see any change that would cause this behaviour. effectiveAppearance is still Aqua.
A NSBox with a boxType of .primary always draws a background. That is intended behaviour. Only if the view behind NSBox is white you may not see it. If you want a NSBox without background you must make it boxType .custom and set the background color as required.

UIImageView Tint Color weirdness

I'm using pdf images in Xcode 10.
The settings are as follows:
As you can see the image has been set to be rendered as Template Image
Now when setting the image in an imageView and setting the tint color, this weird thing happens:
If the tint color is not white or any white hue, it is rendered correctly on the phone
If the tint color is set to white or any hue that is white (light gray, etc), then it's rendered fine in the Interface Builder, but it appears black on the phone
I even tried setting the tint color at runtime, but same thing happens.
Any clues why this is happening?
I'm starting to think this is a bug in Xcode, but wondering if I missed something!
Ok, this seems to be indeed a bug.
Found this:
http://openradar.appspot.com/23759908
And yes, calling tintColorDidChange in viewWillAppear does solve the problem.

How to "tint" UIVisualEffectView on iOS 8+? Or, create a blurred background view with a tint color?

Self-explanatory. UIVisualEffectView only has a light, dark, and "extra light" tint variation. Is there a way to tint with a color instead, such as the tint color of the app?
UINavigationBar sort of does this, I think, in that it has transparency and blur... but also a tint color.
Third-party libraries are OK, but I'm not sure where to look for this.
You can tint the UIVisualEffectView using this library:
https://github.com/efremidze/VisualEffectView
Set a UIView with an alpha of 0.5 or so with a background color. In front of that put a UIVisualEffectView. Remember to not set the visual effect view as a subview of the first background view.
That should do the trick.
It seems like FXBlurView is the way to go currently for tinted blurs. https://github.com/nicklockwood/FXBlurView
You could maybe put it in a UIView that had a semi-opaque background color of the opacity to your liking...

Set Colour Of Vector Image In Xcode 6+

I saw one of the Apple Videos mention that you can colour images via the code. All my searches on how to do this came up blank.
If I have a black vector image (pdf) saved inside Images.xcassets, how can I colour that image at run time?
Ideally it would be something simple like [UIImage setVectorColor:UIColorBlue] but I'm sure there could be more to it!
You have to set all vectors image as Template Image on Render options in the xassets. (http://i.stack.imgur.com/oTuDC.png)
After, you can set the color in the uiimageview which contain your image with method :
[imageView setTintColor:[UIColor redColor]];

How to change the background color of an image in Xcode?

In my program, I need to add some images on the GUI. However, the background color of the image is not the same as the background color of the view.
I know that there is a property used to change the image background. However, when I change the feature of this item, there is nothing happen. Do I miss some settings before adding the image on the project such that I cannot change the background color of the image? Thank you so much for your emergent help!
Change of ImageView's background is possible, but not of Image's.
You can do it by specifying the desired color of ImageView.
[imageViewName setBackgroundColor:[UIColor redColor]];
Or you can specify the RGB values.
[imageViewName setBackgroundColor:[UIColor colorWithRed:0.5 green:0.0 blue:1 alpha:1.0]];
You can't change the background of the image. But you can change the background color of imageview that contains the image.

Resources