Skip to content

Instantly share code, notes, and snippets.

@psobko
Created November 21, 2013 17:12
Show Gist options
  • Select an option

  • Save psobko/7585681 to your computer and use it in GitHub Desktop.

Select an option

Save psobko/7585681 to your computer and use it in GitHub Desktop.
From Cheddar iOS app
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
_editing = editing;
self.textField.enabled = !_editing;
void (^change)(void) = ^{
_textField.alpha = _editing ? 0.0f : 1.0f;
_renameListButton.alpha = _editing ? 1.0f : 0.0f;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if (self.frame.size.width < 500.0f) {
_archiveTasksButton.alpha = _renameListButton.alpha;
_archiveAllTasksButton.alpha = 0.0f;
_archiveCompletedTasksButton.alpha = 0.0f;
} else {
_archiveTasksButton.alpha = 0.0f;
_archiveAllTasksButton.alpha = _renameListButton.alpha;
_archiveCompletedTasksButton.alpha = _renameListButton.alpha;
}
} else {
_archiveTasksButton.alpha = _renameListButton.alpha;
}
};
if (animated) {
[UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationCurveEaseInOut | UIViewAnimationOptionAllowUserInteraction animations:change completion:nil];
} else {
change();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment