0

I am able to get a view with horizontal bar chart with per with the help of UIProgressBar in a UITableView,

Current Output

Current Output

//TEST DATA:
arrShareNames = ["Infosys","TCS","Reliance","Wipro"]
arrSharepercent = [30,40,21,10]

if let progressView = self.view.viewWithTag(101) as? UIProgressView {
    progressView.progress = 0.0
    progressView.progress =  Float(arrSharepercent[indexPath.row]/100)
    progressView.progressViewStyle = UIProgressViewStyle.bar
    progressView.transform = CGAffineTransform(rotationAngle: CGFloat(-Double.pi));
}

I want to append percentage values next to each of the bars of the graph as follows:

Desired Output

Desired Output

How can we add the progress percentage label at the end of the progress bars like this?

Sateesh Yemireddi
  • 4,289
  • 1
  • 20
  • 37
  • You should use some bar chart library instead. – jack jay Nov 13 '18 at 08:49
  • @jack jay, I tried using Charts library by Daniel Gindi, I couldn't make the axis move to the centre and adjust the labels as per the design above, hence decided to use UIProgressBar. It's just the way I wanted now, only the labels are missing. I am hoping to achieve this without the help of a third party library, any help/tips will be greatly appreciated. – iOS Developer Nov 13 '18 at 11:32
  • If you have made it with XIB, then place a label against your progress bar and set horizontal spacing from its trailing to progress bars leading. – jack jay Nov 13 '18 at 12:06
  • @jack jay, Thanks for the reply, although this solution won't work for me since all the progress bars have same width on the XIB i.e the red part is the progress and there is unseen progress bar with clear color is present and the labels will be displayed after the entire progress bar which will not be as per the desired design, I need to display the labels next to the highlighted red progress so that it will look like the desired output. I need a way for displaying the labels immediately next to the red progress bar when it ends, and not at the end of each progress bar. – iOS Developer Nov 13 '18 at 12:55

0 Answers0