0

I am displaying a list of users and their respective badges they have won, so each user has three different counts (gold, silver, bronze). In addition to displaying the # of badges they've earned, I want to have a rectangle in the background that is resized depending on how many badges they have (kind of like a bar chart).

This is how I am attempting to do it so far. (I have a UIView called goldRect in my storyboard, with a height of 20 and width of only 1 pixel to start.) Then I do:

cell.goldRect.frame = CGRectMake(cell.goldRect.frame.origin.x, cell.goldRect.frame.origin.y, 28*numGolds, cell.goldRect.frame.size.height);

But nothing changes, the bar still remains at width one pixel. Any help?

Kelly
  • 186
  • 3
  • 15
  • Animations!! or try this SO post: https://stackoverflow.com/questions/18850871/cgrectmake-is-not-working-with-uiview?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Eccentric Eric Jun 07 '18 at 22:15
  • Are you want to change the width or height? Suppose you want to change the width you mentioned only 28*numGolds not all badges, you mention all badges count here. 28*allBadgesCount. – Naresh Jun 08 '18 at 05:30

1 Answers1

0

Use this code

cell.goldRect.frame = CGRectMake(cell.goldRect.frame.origin.x, cell.goldRect.frame.origin.y, 28*numGolds, 20);

In your case, you not change gold rect height, because you set it to cell.goldRect.frame.size.height. The same what it was.