我有一个按钮,可在全屏上显示弹出式窗口,主视图有6个自定义视图,其中有5个按钮带有灰色或蓝色(取决于某些参数)的色调。但是当弹出窗口出现时,海关视图内的按钮变为灰色,一旦弹出窗口不显示自定义视图为淡色,我想避免当弹出窗口出现时按钮色调不会改变。 自定义视图是uitableviewCell内部的视图。自定义视图就是这样定义的。
class ratingDoors: UIView {
var rating: Int = 0{
didSet{
makeRating()
}
}
@IBOutlet var contentView: UIView!
@IBOutlet weak var button1: UIButton!
@IBOutlet weak var button2: UIButton!
@IBOutlet weak var button3: UIButton!
@IBOutlet weak var button4: UIButton!
@IBOutlet weak var button5: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
//fatalError("init(coder:) has not been implemented")
}
private func commonInit() {
//TODO: Do some stuff
// 1. Load the nib
Bundle.main.loadNibNamed("ratingDoors", owner: self, options: nil)
// 2. Add the 'contentView' to self
addSubview(contentView)
contentView.frame = self.bounds
contentView.autoresizingMask = [.flexibleHeight,.flexibleWidth]
}
@IBAction func setRating(sender: UIButton){
rating = sender.tag
//makeRating()
}
func makeRating() {
button1.configureRatingButton(i: rating)
button2.configureRatingButton(i: rating)
button3.configureRatingButton(i: rating)
button4.configureRatingButton(i: rating)
button5.configureRatingButton(i: rating)
}
}
extension UIButton{
func configureRatingButton(i: Int){
if self.tag <= i {
self.tintColor = UIColor(red: 90/255, green: 212/255, blue: 227/255, alpha: 1.0)
}else{
self.tintColor = UIColor(red: 204/255, green: 204/255, blue: 204/255, alpha: 1)
}
}
}
在表格视图中,我为单元格设置了
let cell = tableView.dequeueReusableCell(withIdentifier: "ratingCell") as! ratingTableViewCell
cell.ratingLabel.text = "Ordenado"
if let ordered = requestManager.instance.user.ordered{
cell.ratingView.rating = ordered
}
return cell
,因此对于具有相同视图的所有6行。 这是prepare(for :)
let popoverVC = segue.destination as! popoverViewController
popoverVC.delegate = self
popoverVC.modalPresentationStyle = UIModalPresentationStyle.popover
popoverVC.popoverPresentationController!.delegate = self
答案 0 :(得分:0)
如果您将每个按钮的cursor.execute(f'''
INSERT INTO pyUser.dbo.user_information (first_name, last_name, profile_photo_path)
VALUES
('{user_first_name}', '{user_last_name}', '{file_name}')
''')
设置为tintAdjustmentMode
,则在显示弹出框时它们将不会调整其色调。另一种选择是使用不响应色调更改的“自定义”按钮类型(而不是“系统”)。
答案 1 :(得分:0)
仅将按钮类型设置为custom
并没有帮助,因此需要将tintAdjustmentMode
设置为.normal
对我有用。
PS。感谢@Jordan H,但是情况有所不同,因此请写一个单独的答案。