iOS – How to set a UISwitch programmatically

If you are using a UISwitch, then as seen in the developer API, the task setOn: animated: should do the trick.

- (void)setOn:(BOOL)on animated:(BOOL)animated

So to set the switch ON in your program, you would use:

Objective-C

[switchName setOn:YES animated:YES];

Swift

switchName.setOn(true, animated: true)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)