Swift, Xcode - 增加 UISwitch 的大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30492731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Swift, Xcode - Increasing the size of a UISwitch
提问by mahclark
I am making my app 'universal' (used on iPhone and iPad) and I have found ways of increasing the size of everything except for UISwitches. Is there a way of doing so?
我正在使我的应用程序“通用”(在 iPhone 和 iPad 上使用),并且我找到了增加除 UISwitches 之外的所有内容大小的方法。有没有办法这样做?
Any help is greatly appreciated.
任何帮助是极大的赞赏。
回答by kabiroberai
According to this answerby the user mxg, just use the following code:
mySwitch.transform = CGAffineTransformMakeScale(0.75, 0.75)
Of course, you have to change mySwitch
to whatever the name of your variable/IBOutlet is.
当然,您必须更改mySwitch
为变量/IBOutlet 的名称。
回答by David Seek
Swift 3 / 4:
斯威夫特 3 / 4:
switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
回答by Khawar Islam
Xcode 9.2 & Swift 4
Xcode 9.2 和 Swift 4
switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
回答by Sethmr
Making a custom one is simple. If you need ideas on how to do so, or would just like to use the one I wrote, try SwiftySwitch. It allows for a good bit more customization than the default UISwitch gives you, and you get direct access to all of it on the storyboard.
定制一个很简单。如果您需要有关如何这样做的想法,或者只想使用我写的那个,请尝试SwiftySwitch。它允许比默认的 UISwitch 提供更多的自定义,并且您可以直接访问故事板上的所有内容。
I don't recommend the other ways because Apple does not like having their tools altered in ways they were not meant to be.
我不推荐其他方式,因为 Apple 不喜欢他们的工具以他们不应该被改变的方式改变。