Top of the page
Close

This is a red error

This is a red error

This is a red error

How to animate UISwitch while switching from function

Ondrej Rafaj on 2009.08.12 17:31:19

I you want to change state of the UISwitch with animation (looks better :)) just check this snippet.

We will be using UISwitch, beginAnimations, setAnimationDuration and commitAnimations

- (IBAction) toggleSwitchWithAnimation: (BOOL) how {
	// beginning the animation
	[UIView beginAnimations:nil context:NULL];
	
	// setting duration of the animatio
	[UIView setAnimationDuration: 0.2];
	
	// setting new value for the switch
	resSwitch.on = how;
	
	// commiting the animation for execution
	[UIView commitAnimations];
}

Ondrej Rafaj

Ondrej Rafaj

Independent iPhone developer @ ondrej-rafaj.co.uk

I am available to give you a free quote or start working on your project ... just give me a call or drop a line. Please find all my details on my portfolio site ondrej-rafaj.co.uk

Back to top Comment

Comments ... Why not to get involved!

We had to disable comments till the problem with spam will be solved, sorry for any inconvenience caused.

Back to top

IE SUCKS, DON'T USE IT :) Digg this page