0

I've got UIimages set to aspect fill covering the entirety of a UITableViewCell.

Each of these cells are representing a Post object I've got that's got a "timeLeft" property on it.

I'm wanting as a progress bar sort of thing to have the bars "drain" from right to left as their timeLeft is draining. So if a cell has 30 seconds left out of 100, the UIImageView would be covering 30% of the cell width and slowly drain down to the left until it's 0%. I don't want the 30% to be a shrunk down version of the photo. I want the first third left side of the photo to show and the rest to be "gone".

I feel like I can accomplish this effect by having a view grow from the right side of the screen and cover up the UIView in an animation making it look like the UIView is shrinking. I'm wondering if there's a better way to accomplish this though? Is it possible to scale down or to do something to an imageView's frame or bounds that reduces its max width number and shrinks the bounds without effecting what's inside of it?

user6820041
  • 1,213
  • 2
  • 13
  • 29
Barkley
  • 6,063
  • 3
  • 18
  • 25

2 Answers2

1

You could try this: Crop UIImage to fit a frame image

or, doing it manually: Create a container view, which then will host the original UIImageView. Put this into the cell and then shrink the container view instead of the UIImageView.

Community
  • 1
  • 1
Andreas Oetjen
  • 9,889
  • 1
  • 24
  • 34
0

You want the image to be revealed gradually as a loading bar? That's what I'm presuming, cause that's what I understood. The way I would do that is by adding a UIView to the screen, and having the UIImageView be the subview of it.enter image description here

Like so with the grey view being the loadingant view. you decrease the size of the loading view while keeping the UIImageView's size constant.

DatForis
  • 1,331
  • 12
  • 19