Swift, Xcode - increasing the size of UISwitch

I make my application “universal” (used on iPhone and iPad), and I have found ways to increase the size of everything except UISwitches. Is there any way to do this?

Any help is greatly appreciated.

+9
source share
5 answers

According to this answer by user mxg , use only the following code:

mySwitch.transform = CGAffineTransformMakeScale(0.75, 0.75) 

Of course you need to change mySwitch to any name of your variable / IBOutlet.

+23
source

Swift 3/4:

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

Creating a custom simple. If you need ideas on how to do this, or just want to use the one I wrote, try SwiftySwitch . This allows you to get a better setting than the default UISwitch you provided, and you get direct access to all this on the storyboard.

I do not recommend other methods, because Apple does not want their tools to be changed the way they should not have been.

+2
source

Xcode 9.2 and Swift 4

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

Xcode 10.1 and Swift 4

  self.MessageNotButton.transform = CGAffineTransform(scaleX: 0.75, y: 0.75) 
0
source

Source: https://habr.com/ru/post/988045/


All Articles