Remove background of an image in image view - swift

How can i edit the background of an image (not imageview) and set it to be transparent. I had search a lot but can find nothing. Any help?

Do you mean you want to do image processing using swift?

Related

How do I blur (ios7 style) a section of an image in a UITableViewCell?

I've got a UIImageView that takes up the whole cell and shows an image. I'd like to blur the bottom third of the view in the iOS7 style (we're targeting iOS7). There will be a label over the blurred part.
The issue seems to be that I can't "screenshot" the UIImageView right as I am setting up the cell in tableView:cellForRowAtIndexPath: as it hasn't loaded yet. Although i've even tried setting up a timer for a 0.1 second delay and that also doesn't work.
I've tried the stuff on http://damir.me/posts/ios7-blurring-techniques
I've tried https://github.com/justinmfischer/7blur
I'd like to use the new screenshotting API drawViewHierarchyInRect:afterScreenUpdates:
I'd also like to use apple's sample code UIImage+ImageEffects
The only thing that has worked so far has been to just put a UIToolbar in but the performance is really slow. I don't need dynamic updates.
I've managed to get the following effect a few times but it has just tinted the view and hasn't actually blurred anything so I'm a bit confused.
Use UIImageEffects sample from apple
Make a Image View with a size of the lower portion you want to blur... and then set its image to a blurred one. also set its content mode to UIViewContentModeBottom for the proper clipping
Since your image isnt the size of the cell.. first get a temp image as it is being displayed in the cell by drawing a UIImage from it.. refer for the code here
How to capture UIView to UIImage without loss of quality on retina display
then blur that image
Load this image into a UIImage, blur the image, clip to fit the area that you want. Use UIImage+blur.h

How i can set background picture for table view and UIView from other class

I've got some url with picture when my player go play. And I want set a background picture to all my views. How I can do this? I need example code.
2 approaches
1) Write a cateogory on ViewController and change the background image in the category.
2) you can set the background image of your main window and set background image of all your views to clear colour.
I would go for the first approach its more elegant

CPGraphHostingView background image issue in IPhone?

I have a CPGraphHostingView to display a graph. I changed its theme to clear color, and add a UIImageView to the CPGraphHostingView in order to add an image as the background of the graph.
But then the image will give only the mirror image like copy of the original image. So when I am taking the screenshot of that view I'm getting the mirror image copy of the original view. How to solve this?
Don't add any subviews to the CPGraphHostingView. If you must use a UIImageView, make it a sibling of the hosting view (i.e., they are both subviews of the same parent).
The easiest way to put an image behind a graph is to set the fill.
CPTImage backgroundImage = [CPTImage imageForPNGFile:pathToTheImage];
graph.fill = [CPTFill fillWithImage:backgroundImage];
You can also create the image using +imageWithCGImage: or +imageWithCGImage:scale: if you already have your background image loaded into a CGImageRef.

iPhone - Make a small image fill a custom larger button

I have a UIButton in which I want to insert an image that would stretch to the button size. The button property allow it to stretch "down" the included image to fit the button size, but I want to do the opposite : the thing is that my image is small, and I want it to grow if the button is bigger than the image.
How may I do this ?
Set the image as the background image of the button.
you can use property value Aspect Fit or something related to it.
I had same problem and after searching i found a good thread.
How do I scale a UIButton's imageView?
I will suggest you to set background image of button which will solve your problem.
And be careful if you are resizing image programatically it will take time to resize. If you have multiple images and you are resizing programatically do it on different background thread which will protect your main thread and GUI will not hang and set resized image on main thread.

What's the difference between setBackgroundImage:Forstate and setImage:Forstate:

I am trying to set a image for a UIButton.
I don't know the difference between the setBackgroundImage:Forstate and setImage:Forstate:
Could anyone help me out?
Thanks and best regards.
setImage:forState: sets the image as the actual content of the button. For example, you can not see the button title even though you set it, because you have set an image as the content.
setBackgroundImage:forState: sets the image as the background. In this case, you can set the title and it is displayed on top of the image.
setBackgroundImage: follows the frame, i.e. if u change the frame, the background image is streched or shrinked with it. Contrary on the setImage, its not the same. The image takes its own size. In setImage the image is the actual content of the button.
The difference is in the framing
I will explain you with the help of example suppose your image size is 40*40 and button frame is 20*20 then if you use setBackgroundImage:forState: method the image will be displayed in 20*20 frame and if you use setImage:forState: method you will see a button with image size of 40*40 frame.
This is the difference.
Happy Coding!!