首页 > 解决方案 > 如何在 - 和 + 符号之间放置步进值?

问题描述

我正在以编程方式尝试自定义 UIStepper。我想将 stepper.value 放在 - 和 + 按钮之间,并且我想将步进器的背景更改为白色。

我该怎么做?

这是我所拥有的不起作用的:

let stepper = UIStepper(frame: CGRect(x: 0, y: 0, width: 200, height: 40))
        stepper.minimumValue = 0
        stepper.center = self.contentView.center
        stepper.backgroundColor = .white
        stepper.layer.backgroundColor = UIColor.white.cgColor
        stepper.stepValue = 1
        stepper.tintColor = UIColor(hex: Constants.Colors.primary)
        stepper.setIncrementImage(UIImage(named: "icon_cart_plus"), for: .normal)
        stepper.setDecrementImage(UIImage(named: "icon_cart_minus"), for: .normal)

标签: swiftstepper

解决方案


推荐阅读