繁体   English   中英

如何使用UISegmentedControl更改Swift中的标签?

[英]How do I use UISegmentedControl to change the labels in Swift?

我是Swift的初学者,所以请多多包涵。

这是使用UISegmentedControl的文档:

码。

每当我尝试使用该代码时,我都会获得编译代码。 我目前正在尝试获取将细分3(自定义)更改为用户输入的任何内容(因此是字符串)的代码。

我努力了:

func setTitle(_ title: "Hello"?,
forSegmentAtIndex segment: 3) 

func setTitle(_ title: Hello?,
forSegmentAtIndex segment: 3)

func setTitle(_ title: "Hello"?,
forSegmentAtIndex segment: Int 3)

不知道如何正确执行此操作,请帮忙!

另外,这是我要制作的应用程序的链接: http : //i.imgur.com/CWoBkHk.gif 我只是真的想要自定义按钮来反映什么是自定义提示%。

尝试这样:-

假设您有出口:-

@IBOutlet weak var segmented :UISegmentedControl?

//Now for changing the title:-
segmented?.setTitle("test1", forSegmentAtIndex: 0)
segmented?.setTitle("test2", forSegmentAtIndex: 1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM