UIProgressView
1 override func viewDidLoad() { 2 super.viewDidLoad() 3 4 titleLabel.text = titleString 5 6 7 // Do any additional setup after loading the view. 8 9 //创建进度控制器 10 var progressView:UIProgressView = UIProgressView(frame: CGRectMake(20, 100, 200, 20)) 11 12 //添加到视图上 13 self.view.addSubview(progressView) 14 15 //设置进度 16 progressView.progress = 0.5 17 //或 18 progressView.setProgress(0.5, animated: true) 19 20 //设置风格 21 progressView.progressViewStyle = UIProgressViewStyle.Default 22 23 // 24 progressView.tintColor = UIColor.greenColor() 25 26 27 //--------使用颜色来美化进度控制器 28 //当前进度颜色 29 progressView.progressTintColor = UIColor.redColor() 30 31 //背景颜色 32 progressView.trackTintColor = UIColor.blueColor() 33 34 35 //--------使用图片来美化进度控制器 36 //设置进度的图片 37 progressView.progressImage = UIImage(named: "leftTrack.png") 38 39 //设置背景图片 40 progressView.trackImage = UIImage(named: "rightTrack.png") 41 42 }
时间: 2024-10-10 13:56:24