# Swift : updating an image

**URL:** <https://ifnotnil.com/t/swift-updating-an-image/2666>\
**Category:** Other\
**Created:** [15 August 2022 23:29 UTC](https://ifnotnil.com/t/swift-updating-an-image/2666 "2022-08-15T23:29:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [15 August 2022 23:29 UTC](https://ifnotnil.com/t/swift-updating-an-image/2666/1 "2022-08-15T23:29:43Z")

</div>

I have an app, where on one view it asks for a grid size  
it then loads another view, and calls a routine (onAppear) the creates an on the fly UIImage  
with a grid the size the user requested… or that is what it is SUPPOSED to do.

The first time, it does if correctly. If I pop that view and go back to the view that ask the size, and select another size, the image DOES NOT change. The log says it did, but it didn’t

info is from the routine that creates the UIImage

FIRST REQUEST

```auto
New Image : 7x6
TileSize=137.71428571428572
ImgSize=(0.0, 0.0, 1024.0, 886.2857142857143)
SafeArea=(0.0, 24.0, 1024.0, 1322.0)
R=(35.0, 35.0, 127.71428571428572, 127.71428571428572)
DONE : (1024.0, 887.0)

```

Second Request

```auto
New Image : 9x9
TileSize=107.11111111111111
ImgSize=(0.0, 0.0, 1024.0, 1024.0)
SafeArea=(0.0, 24.0, 1024.0, 1322.0)
R=(35.0, 35.0, 97.11111111111111, 97.11111111111111)
DONE : (1024.0, 1024.0)

```

as you can see the first creates a 1024x887 image with a grid 7x6  
the 2nd “says” it created a 1024x1024 image with a grid 9x9 but I still see a 7x6

If I go from BIGGER to Smaller it does seem to work, but not smaller to bigger

---

<div class="post-metadata">

**Author:** ![DaveS](https://ifnotnil.com/user_avatar/ifnotnil.com/daves/32/79_2.png) [@DaveS](https://ifnotnil.com/u/DaveS)\
**Post date:** [16 August 2022 00:01 UTC](https://ifnotnil.com/t/swift-updating-an-image/2666/2 "2022-08-16T00:01:54Z")

</div>

Solved… I needed to add the equivalent of “view.refresh”…
