Swift, Xcode - Increasing the size of a UISwitch

有些话、适合烂在心里 提交于 2019-12-05 00:55:38
kabiroberai

According to this answer by 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.

Swift 3 / 4:

switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)

Xcode 9.2 & Swift 4

switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)

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.

I don't recommend the other ways because Apple does not like having their tools altered in ways they were not meant to be.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!