- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我想在 Swift 3 中更改 UISegmentedControl 选定段的 tintColor。我在 Objective-c 中搜索了很多答案...
这是我的代码:
class ViewController:UIViewController{
var segment:UISegmentedControl
override func viewDidLoad() {
super.viewDidLoad()
segment.insertSegment(withTitle: "AAA", at: 0, animated: true)
segment.insertSegment(withTitle: "BBB", at: 1, animated: true)
segment.insertSegment(withTitle: "CCC", at: 2, animated: true)
segment.addTarget(self, action: #selector(changeValue), for: .valueChanged)
segment.selectedSegmentIndex = 0
view.addSubview(segment)
}
func changeValue(sender:AnyObject) {
//I don't know how to do that change color when segment selected
//
}
}
谢谢!
最佳答案
在 ios 13 以上使用下面的代码,
if #available(iOS 13.0, *) {
segment.selectedSegmentTintColor = .red
} else {
segment.tintColor = .red
}
关于ios - 如何在 Swift 中更改 UISegmentedControl 的选定段 tintColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41544625/
根据以下文档 ( https://developer.apple.com/documentation/uikit/uisegmentedcontrol/1618570-settitletextattr
我试图在登录时隐藏 nameTextField 并使其在注册时显示切换。我一直试图自己解决这个问题,但这就是我所得到的。我已经把它归结为两个错误,它们是相同的。 Issue Navigator laz
我有两个 UISegmentedControl,我想用其中一个来启用/禁用另一个。我编写了一个函数来处理这个问题,如下所示: - (void)disableSegment2 { if (
我有一个以编程方式定义的 UISegmentedControl。 我正在尝试添加布局约束,以便当我的 iPad 旋转时,分段控件在旋转 View 中正确调整大小,而不是溢出屏幕。 我应用了以下约束:
如何通过再次按下同一段来取消选择 UISegmented 控件中的给定段? 例如按下段 0,它将被选中并保持突出显示。再次按下段 0,它将变为未选中且未突出显示。 该控件仅触发 UIControlEv
我正在为我的分段控件设置颜色,如下所示: segmentedControl.backgroundColor = .gray segmentedControl.selectedSegmentTintCo
我在 iOS7 中更改分段控件的边框颜色时遇到问题。我在 stackoverflow 的其他地方找到了以下建议: [[UISegmentedControl appearance] setTit
是否可以让 UISegmentedControl 在 iPhone 上跨越两行?我已经在一些应用程序中看到了这一点,但没有在文档中找到我需要的内容。也许它是一个自定义的 UIButton,设计得像 U
我的应用程序中有一个 UISegmentedControl(请参阅下面的代码): // --------------- SETTING NAVIGATION BAR RIGHT BUTTONS NSA
我的 iPhone 应用程序中有一个分段控件,在 ios6 上运行良好,但在 ios7 上,分段图 block 被截断(有足够的空间容纳文本,但无论如何都会截断它们) self.segment
这个问题已经有答案了: 已关闭10 年前。 Possible Duplicate: How to change font color of UISegmentedControl 是否可以为 selec
有没有办法通过编程使UIsegmentedControl具有方角?请帮忙!!! 最佳答案 您可以为将完全覆盖边框的片段设置背景图像。如果背景图像是方形的,那么分段控件将显示为方形。对您想要自定义的每个
如何制作多行 UISegmentedControl。我需要它有 6 个按钮,每行 3 个。我如何以编程方式执行此操作? 最佳答案 您将需要使用其中两个,并使用 selectedSegmentIndex
我正在使用带有一些自定义图像的 UISegmentedControl: UISegmentedControl *segmentedControl = [[UISegmentedControl allo
有没有办法摆脱 UISegmentedControl 的圆角或者它是默认行为? 最佳答案 有一些非常简单的方法可以让您摆脱 UISegmentedControl 上的圆形垃圾...将样式更改为“7”。
就像标签栏一样,我想在 UISegmentedControl 上显示徽章。因为我看不到 UISegmentedControl 的任何预定义方法,就像可用于 UITabBar 的方法一样。 我考虑过将徽
如何获得一个类似于邮件应用程序中的 UISegmentedControl,以便它与 UIToolbar 按钮颜色相同(就好像两个段都处于选定状态一样)。 我想使用分段控件来实现与 Mail 完全相同的
这可能是一个非常简单的问题,但我似乎无法在 API 或任何搜索引擎中找到任何内容。 我有一个分段控件,我已将其设置为瞬时,因为用户将选择他们想要搜索的几个汽车品牌。我遇到的问题是我似乎无法弄清楚如何识
当我将整个导航栏设置为黑色时,通常在所选按钮上的 UISegmentedControl 上显示的色调不会显示(self.navigationController.navigationBar.tintC
我想为 UISegmentedControl 提供以下方面: 注意灰色背景 View ,以及分段控件未选定项目的白色背景。 但是,如果我为 UISegmentedControl 提供白色背景,我会得到
我是一名优秀的程序员,十分优秀!