Seems like since this is a user preference, the correct place to save it would be in the NSUserDefaults, so you can try this in your settings:
The switch should be a "Not show animation", so when it is On, is not showing the animation, and initially would be Off(which shows the animation)
-(IBAction)onOffSwitch:(UISwitch *)sender{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:sender.on forKey:@"ShouldNotShowAnimation"];
[defaults synchronize];
}
And in your animation, you can add
- (void) animateTabBar{
if ([NSUserDefaults standardUserDefaults] boolForKey:@"ShouldNotShowAnimation"]) return;
[UIView animateWithDuration:(TAB_BAR_ANIMATION_TIME / 2) animations:^{
CGPoint rightOffset = CGPointMake(self.tabBarScrollView.contentSize.width - self.tabBarScrollView.bounds.size.width, 0);
[self.tabBarScrollView setContentOffset:rightOffset];
} completion:^(BOOL finished) {
[UIView animateWithDuration:(TAB_BAR_ANIMATION_TIME / 2) animations:^{
[self.tabBarScrollView setContentOffset:CGPointMake(0, 0)];
}];
}];
}
I added just one line, that checks in the user defaults and then quits (no animation) if "ShouldNotShowAnimation" is YES.
If it is no, then it will show the animation. And since the boolForKey: returns NO if it cannot find the user default, it will show the animation if it has not been set before.
EDIT
To show the UISwitch correctly in the settings view, add this in the viewWillAppear method
self.switch.on = [NSUserDefaults standardUserDefaults] boolForKey:@"ShouldNotShowAnimation"];