UISwitch

Discussion in 'iOS Programming' started by yaniv92648, Mar 11, 2010.

  1. yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #1
    Hi,
    Anyone knows how to resize a UISwitch?
    i tried setFrame, setBounds, etc.. nothing worked..
    Thanks.
     
  2. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #2
    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.
     

    Attached Files:

  3. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #3
    did u try to make it bigger also?

    not only smaller?
     
  4. KoolStar macrumors demi-god

    KoolStar

    Joined:
    Oct 16, 2006
    Location:
    Kentucky
    #4
    Yes, you can make it larger by using values larger than 1.
    Code:
    sw.transform = CGAffineTransformMakeScale(2, 2);
    
     

Share This Page