簡単なカスタマイズprogressView【swift】

UIProgressViewはデザインがバージョンごとに変わるしなんか微妙なので、デザインの変わらないプログレスバー

ちなみに全体にroundを付けて、中のバーにもroundがついています

import UIKit

@IBDesignable class RoundProgressBar : UIView {

    var progress:Float!

    var progressBarView:UIView!

    var cornerRadius:CGFloat = 5.0{
        didSet{
            layer.cornerRadius = cornerRadius
            progressBarView.layer.cornerRadius = cornerRadius
        }
    }

    var progressTintColor:UIColor = UIColor.yellow(){
        didSet{
            progressBarView.backgroundColor = progressTintColor
        }
    }

    var progressBackgroundColor:UIColor = UIColor.black(){
        didSet{
            self.backgroundColor = progressBackgroundColor
        }
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        commonInit()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        commonInit()
    }

    func commonInit(){
        progressBarView = UIView(frame: self.bounds)

        layer.cornerRadius = cornerRadius
        layer.masksToBounds = true
        layer.borderWidth = 0.8
        layer.borderColor = UIColor.black().CGColor
        clipsToBounds = true
        self.backgroundColor = progressBackgroundColor

        progressBarView.layer.cornerRadius = cornerRadius
        progressBarView.layer.masksToBounds = true
        progressBarView.layer.borderWidth = 0.8
        progressBarView.layer.borderColor = UIColor.black().CGColor
        progressBarView.clipsToBounds = true
        progressBarView.backgroundColor = progressTintColor

        addSubview(progressBarView)
    }

    func setProgress(progress :Float){
        self.progress = progress
        self.progressBarView.frame = CGRectMake(0, 0, self.frame.size.width * CGFloat(progress), self.frame.size.height)
    }
}