iosuiswitch

Changing UISwitch width and height


I am trying to change the default height and width of a UISwitch element in iOS, but unsuccessfully.

Can you change the default height and width of a UISwitch element?
Should the element be created programmatically?


Solution

  • I tested the theory and it appears that you can use a scale transform to increase the size of the UISwitch

    UISwitch *aSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(120, 120, 51, 31)];
    aSwitch.transform = CGAffineTransformMakeScale(2.0, 2.0);
    [self.view addSubview:aSwitch];