Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yaniv92648

macrumors member
Original poster
Oct 26, 2009
96
0
Hi,
Anyone knows how to resize a UISwitch?
i tried setFrame, setBounds, etc.. nothing worked..
Thanks.
 
You have to use the transform property.

Code:
	UISwitch *sw=[[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 5, 5)];
	sw.transform = CGAffineTransformMakeScale(.5, .5);
	[self.view addSubview:sw];
That is just a quick sample if you were to create the switch in code. If you created it in IB you just need to create an IBOutlet and modify the transform property of the IBOutlet. By the way the transform above makes the switch half its normal size.
 

Attachments

  • Screen shot 2010-03-11 at 8.05.25 AM.png
    Screen shot 2010-03-11 at 8.05.25 AM.png
    14.6 KB · Views: 146
  • Screen shot 2010-03-11 at 8.05.55 AM.png
    Screen shot 2010-03-11 at 8.05.55 AM.png
    14.5 KB · Views: 150
Yes, you can make it larger by using values larger than 1.
Code:
sw.transform = CGAffineTransformMakeScale(2, 2);
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.