iOS 无法为 UIStepper 设置递增和递减图像

标签 ios uikit uistepper

我可以通过以下方式设置背景图像:

self.setBackgroundImage(image, for: .normal)

但是如果我这样做:

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

增量侧将“+”更改为蓝色方 block ,如下所示:

enter image description here

减量边实际上也是一个蓝色矩形,只是因为它的大小与减号完全相同,所以它看起来仍然像一个减号。我可以通过给它不同的尺寸来纠正这个问题。

有人处理过这个吗?与背景相反,增量/减量边的图像有什么特别之处吗?

最佳答案

Is there something special about the images

当然,它们是模板图像。如果那不是你想要的,你需要调用 UIImage withRenderingMode制作非模板图像 (.alwaysOriginal)。

关于iOS 无法为 UIStepper 设置递增和递减图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41858136/

相关文章:

ios - 为什么 NULL 需要用 block 进行类型转换?

iOS 旧应用程序屏幕尺寸

ios - Swift Alamofire 从刷新 token 请求错误中获取 token

ios - UIStepper.value 变成科学计数法

ios - 如何从 UITableViewCell 内部判断其父 TableView 何时被弹出?

ios - Xcode 10.0 : Failed with exit code 1

uikit - addSubView SwiftUI View to UIKit UIView in Swift

uiview - iOS 应用程序 UI 的层次结构

ios - 在iPhone和iPad上,我们可以不使用drawRect来绘制任何东西吗?

flutter - 如何在 flutter 中创建类似箭头标签的设计