Skip to content

Instantly share code, notes, and snippets.

@warriorg
Created November 7, 2015 05:11
Show Gist options
  • Save warriorg/bfcb94685218b13f89b3 to your computer and use it in GitHub Desktop.
Save warriorg/bfcb94685218b13f89b3 to your computer and use it in GitHub Desktop.
UIView 增加触摸效果
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:227/255.0 green:227/255.0 blue:227/255.0 alpha:1.0]];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesCancelled:touches withEvent:event];
[self setBackgroundColor:[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment