Swift 3: How to change button's image to UIImageView's image - uiimageview

Is there any way I can change UIButton's image to UIImageView's image?
The UIImageView's image is from database.
Any help is appreciated, thank you so much!

You can just set the button's image to imageView.image.
button.setImage(imageView.image, for: .normal)

Related

Add Background Image to UITableView programmatically

I am trying to add a background image to a table view. I am using Xcode and swift.
Use the .backgroundView property on your tableview object and set it with whatever UIImageView you want. UITableView Apple Reference Docs
tableView.backgroundView = UIImageView(image: UIImage(named: "something.png"))
You can also add image like this way also:
tableView.backgroundColor = UIColor(patternImage: UIImage(named: "your_image_name")!)
Add imageView to background layer and set what ever image to that image view .And set table view background color & cell color to clear.

Xcode -Set UIIMageView equal width-height with UITableViewCell

I am building my custom cell and I want an ImageView to be equal with the Cell size(constraints for Height,Width) but I noticed that there is not option for that like other views(eg UIView). Am I missing something here or is there any workaround?
Thank you.
Solution: Add constraints to center the Image View Horizontaly/Vertical and for Bottom/Top space.

How to put a nav-bar in header image such that the nav-bar is transparent?

I have to place navigation bar in the header image, such that it becomes transparent and i'm using the theme Diario. I know how to make nav-bar transparent but donot know how to position it on the header image.
Please help.
Thanking a lot in advance.
you could always use position: absolute so that you can move it without moving anything else

How to make UIImage rounded,Not rounded corner

Draw a circle,make a rounded UIImageView in it.How to get this, please guide me.
thx!
Let's put it this way,
First we create a UIImageView to the size of the circle you want.Let's say you want this image to be a circular image,
http://united4iran.org/wp-content/uploads/2010/11/cell-phone-in-canada.jpg
Then you create another UIImageView one top of the previous one to the size of 320x480 and set this image to it (Assume this image size is 320x480),
Note: also remember that inner area of the circle in above image is transparent.
Then you should get a image like this,
http://img580.imageshack.us/img580/782/testjkn.png
Hope this will help you.

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