iOS的故障设定增量和减量图片UIStepper

问题描述:

我能够设置背景图片罚款:iOS的故障设定增量和减量图片UIStepper

self.setBackgroundImage(image, for: .normal) 

但是,如果我做这些:

self.setDecrementImage(image, for: .normal) 
self.setIncrementImage(image, for: .normal) 

增加侧改变“ +”成蓝色正方形像这样:

enter image description here

减量侧也实际上是一个蓝色的矩形,除了它是减号的确切尺寸外,它仍然看起来就像一个减号。我可以通过给它一个不同的大小来纠正这个问题。

有人处理过这个吗?增加/减少边的图像是否与背景相反?

是不是有什么特别的图像

当然,他们是模板图像。如果这不是您想要的,则需要调用UIImage withRenderingMode以制作非模板图像(.alwaysOriginal)。

+0

从我的书精细工作可下载的例子,在这里:https://github.com/mattneub/Programming-iOS-Book-Examples/blob/master/bk2ch12p580stepper/ch25p853stepper/ViewController.swift – matt