How do I set the background image size of a table cell in swift?

Alex

So far I have:

var imageView = UIImageView(frame: CGRectMake(10, 10, cell.frame.width - 10, cell.frame.height - 10))
let image = UIImage(named: ImageNames[indexPath.row])
imageView.image = image
cell.backgroundView = imageView

This sets the background image, but my goal is to have 10 pixels worth of padding on either side. This is just filling the background of the cell with this image.

Alex

I actually was able to fix my own problem. I just created the background view and then added a subview to it like this:

let imageView = UIImageView(frame: CGRect(x: 10, y: 10, width: cell.frame.width - 10, height: cell.frame.height - 10))
let image = UIImage(named: "Image Name")
imageView.image = image
cell.backgroundView = UIView()
cell.backgroundView!.addSubview(imageView)

This prevents anything from being covered up and achieves the effect I wanted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I set the background image size in CSS?

From Dev

How do I set background image to a Canvas

From Dev

how do I zoom a background image on a div with background-size

From Dev

How to set background image in swift?

From Dev

How can I add an image to my table cell in swift?

From Dev

How do I animate background image size on hover smoothly in css?

From Dev

How do I animate background image size on hover smoothly in css?

From Dev

how to set a table background image

From Dev

how to set a table background image

From Dev

How to Set the Background Color of a Cell in a MigraDoc Table

From Dev

How do I resize a constrained imageView, inside a table cell, in swift?

From Dev

How do I set the content of a label to a database table cell in WPF?

From Dev

How do I add a background image and label to a UIBarButtonItem using Swift

From Dev

How do I set a background image using Xcode?

From Dev

How do I set background image with picasso in code

From Dev

How do I set a background image in LibreOffice Writer 5?

From Dev

how to set size of canvas to its background image?

From Dev

How to set the background image according to screen size?

From Dev

how to set size of canvas to its background image?

From Dev

How to set button background image size

From Dev

How do I set the background color of the editing accessory of a table view?

From Dev

How do I set the background color of the editing accessory of a table view?

From Dev

How do I set the size of an image within a ListView?

From Dev

Swift table view with a cell that is transparent and shows background image

From Dev

background image and size of the screen: how to do it correctly?

From Dev

How to set a background image in Xcode using swift?

From Dev

how to set a background image as colorWithPatternImage in swift

From Dev

How do I set collection view's cell size via the auto layout

From Dev

how to set background image in uitableview cell in ios7?

Related Related

  1. 1

    How do I set the background image size in CSS?

  2. 2

    How do I set background image to a Canvas

  3. 3

    how do I zoom a background image on a div with background-size

  4. 4

    How to set background image in swift?

  5. 5

    How can I add an image to my table cell in swift?

  6. 6

    How do I animate background image size on hover smoothly in css?

  7. 7

    How do I animate background image size on hover smoothly in css?

  8. 8

    how to set a table background image

  9. 9

    how to set a table background image

  10. 10

    How to Set the Background Color of a Cell in a MigraDoc Table

  11. 11

    How do I resize a constrained imageView, inside a table cell, in swift?

  12. 12

    How do I set the content of a label to a database table cell in WPF?

  13. 13

    How do I add a background image and label to a UIBarButtonItem using Swift

  14. 14

    How do I set a background image using Xcode?

  15. 15

    How do I set background image with picasso in code

  16. 16

    How do I set a background image in LibreOffice Writer 5?

  17. 17

    how to set size of canvas to its background image?

  18. 18

    How to set the background image according to screen size?

  19. 19

    how to set size of canvas to its background image?

  20. 20

    How to set button background image size

  21. 21

    How do I set the background color of the editing accessory of a table view?

  22. 22

    How do I set the background color of the editing accessory of a table view?

  23. 23

    How do I set the size of an image within a ListView?

  24. 24

    Swift table view with a cell that is transparent and shows background image

  25. 25

    background image and size of the screen: how to do it correctly?

  26. 26

    How to set a background image in Xcode using swift?

  27. 27

    how to set a background image as colorWithPatternImage in swift

  28. 28

    How do I set collection view's cell size via the auto layout

  29. 29

    how to set background image in uitableview cell in ios7?

HotTag

Archive