// // RaitingControl.swift // FoodManagerment // // Created by CNTT on 4/27/21. // Copyright © 2021 Nam Ngọc. All rights reserved. // import UIKit @IBDesignable class RaitingControl: UIStackView { //mark private var raitingButton = [UIButton]() @IBInspectable var starNumber:Int = 5 { didSet{ raitingButtonSetting() } } @IBInspectable var starSize:CGSize = CGSize(width: 44.0, height: 44.0){ didSet{ raitingButtonSetting() } } //contructor override init(frame: CGRect) { super.init(frame: frame) raitingButtonSetting() } required init(coder: NSCoder) { super.init(coder: coder) raitingButtonSetting() } //Initialization of rating control func raitingButtonSetting() { //load the rating images let bundle=Bundle(for: type(of: self)) let nomal=UIImage(named: "Nomal",in:bundle,compatibleWith: .none) let selected=UIImage(named: "Selected",in:bundle,compatibleWith: .none) let pressed=UIImage(named: "Pressed",in:bundle,compatibleWith: .none) //clear the old button for button in raitingButton{ removeArrangedSubview(button) button.removeFromSuperview() } raitingButton.removeAll() for _ in 0..