12

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?

Any help is greatly appreciated.

mahclark
  • 305
  • 1
  • 2
  • 10

4 Answers4

26

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.

Community
  • 1
  • 1
kabiroberai
  • 2,930
  • 19
  • 34
8

Swift 3 / 4:

switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
David Seek
  • 16,783
  • 19
  • 105
  • 136
5

Xcode 9.2 & Swift 4

switch.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
Khawar Islam
  • 2,556
  • 2
  • 34
  • 56
2

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.

Sethmr
  • 3,046
  • 1
  • 24
  • 42