How to change the background color of an image in Xcode? - 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.

Related

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]];

iOS 7 BarTintColor

Have any one else noticed in iOS7, the translucent navigation bar only shows color underneath if barTintColor is set to default?
I tried setting barTintColor to various different colors, but anything that is below the navigation bar is displayed a a black blur. Whereas if the barTintColor is set to default, all the elements display correctly underneath.
Is there a way to force it to show the correct colors?
You have to use background color instead of tint color.
self.navigationController.navigationBar.backgroundColor = [UIColor yellowColor];
If you are using tint color it changes only barbutton background color change.
In MyTabBarController in the storyboard select the color tint. You will change the button active color background. No idea for the inactive one.

removing white background in 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];

how to set background color to IKImageBrowserView

I am new to cocoa..
I am creating one of the colorful window. so I need set background color to IKImageBrowserView. I think subclassing IKImageBrowserView is the way to set background color but it is too difficult for me..
Any other way to set background color without subclassing?
You can achieve what You want by using setValue:forKey with option key IKImageBrowserBackgroundColorKey like this:
[imageBrowserViewOutlet setValue:[NSColor redColor] forKey:IKImageBrowserBackgroundColorKey];
Note: imageBrowserViewOutlet is IKImageBrowserView outlet.
You can do that by using:
[thumbnailBrowser setValue:[NSColor colorWithDeviceRed:0.125f green:0.145f blue:0.145f alpha:1.0f] forKey:IKImageBrowserBackgroundColorKey];
Change RGB as you like. thumbnailBrowser is IKImageBrowserView. Gook luck!

Resources