Skip to content

[Swift] value of central labelview not updated in progressChangedBlock #10

Description

@zyqu1990

Nice project!

I am integrating UAProgressView in my project written in swift. I tried to update the value of the current progress as follows:

override func awakeFromNib() {
    super.awakeFromNib()
    self.progressView.borderWidth = 2.0
    self.progressView.lineWidth = 8.0
    self.progressView.fillOnTouch = false
    self.progressView.animationDuration = 2.0

    self.textLabel = UILabel(frame: CGRectMake(0, 0, 60.0, 32.0))
    self.textLabel.font = UIFont(name: "HelveticaNeue-UltraLight", size: 22)
    self.textLabel.textAlignment = NSTextAlignment.Center
    self.textLabel.textColor = self.progressView.tintColor
    self.textLabel.backgroundColor = UIColor.clearColor()
    self.progressView.centralView = self.textLabel



    self.progressView.progressChangedBlock = { (progressView:UAProgressView!,  progress:Float) -> () in
        let lableview = progressView.centralView as! UILabel
        lableview.text = StringManager.float2str(progress*100)
        println("Current progress")
        println(progress)
    }  
} 

But the block is invoked only once as in the main code:

self.scoreshareview.setViewProgress(StringManager.str2float(score))

function setViewProgress:

func setViewProgress(score:Float){
    self.progressView.setProgress(score/100, animated: true)
}

I am new to iOS and not sure where the problem is.

Thanks for sharing!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions