Sporshiya Islam
Sporshiya Islam

Reputation: 81

How to increase uiswitch Thumb size

I was trying to increase thumb size of a UISwitch I was trying to increase thumb size by set on the image but the image is not showing.

I try this:

uiSwitch.onImage = UIImage(named: "sing") 

i want switch like this

here is image

Upvotes: 1

Views: 2589

Answers (3)

Deep
Deep

Reputation: 436

Create extension :

extension UISwitch {

func increaseThumb(){
    if let thumb = self.subviews[0].subviews[1].subviews[2] as? UIImageView {
        thumb.transform = CGAffineTransform(scaleX:1.5, y: 1.5)
    }
  }
}

Use:

 customSwitch.increaseThumb(

Upvotes: 2

Mjd Mz
Mjd Mz

Reputation: 121

if let thumbView = try (mySwitch.subviews[0].subviews[3] as? UIImageView) {
       thumbView.transform = CGAffineTransform(scaleX:1.5, y: 1.5)
   }

Upvotes: 3

snjmhj
snjmhj

Reputation: 1081

If you want exactly as image you refered https://github.com/JunichiT/JTMaterialSwitch

If you want to increase the only the thumb size of the UISwitch itself, you can't. You must increase the size of UISwitch.

Upvotes: 1

Related Questions