| Index: ios/chrome/browser/ui/fancy_ui/colored_button.mm
|
| diff --git a/ios/chrome/browser/ui/fancy_ui/tinted_button.mm b/ios/chrome/browser/ui/fancy_ui/colored_button.mm
|
| similarity index 54%
|
| rename from ios/chrome/browser/ui/fancy_ui/tinted_button.mm
|
| rename to ios/chrome/browser/ui/fancy_ui/colored_button.mm
|
| index b0c06a608926d0828dde8e096bd77eeb9b319fb9..e5daa5455d25e12ff7572f78b2ab7bef8ac092a2 100644
|
| --- a/ios/chrome/browser/ui/fancy_ui/tinted_button.mm
|
| +++ b/ios/chrome/browser/ui/fancy_ui/colored_button.mm
|
| @@ -2,23 +2,28 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ios/chrome/browser/ui/fancy_ui/tinted_button.h"
|
| +#include "ios/chrome/browser/ui/fancy_ui/colored_button.h"
|
|
|
| #if !defined(__has_feature) || !__has_feature(objc_arc)
|
| #error "This file requires ARC support."
|
| #endif
|
|
|
| -@interface TintedButton () {
|
| +@interface ColoredButton () {
|
| UIColor* normalStateTint_;
|
| UIColor* highlightedTint_;
|
| + UIColor* normalStateBackgroundColor_;
|
| + UIColor* highlightedBackgroundColor_;
|
| }
|
|
|
| // Makes the button's tint color reflect its current state.
|
| - (void)updateTint;
|
|
|
| +// Makes the button's background color reflect its current state.
|
| +- (void)updateBackgroundColor;
|
| +
|
| @end
|
|
|
| -@implementation TintedButton
|
| +@implementation ColoredButton
|
|
|
| - (void)setTintColor:(UIColor*)color forState:(UIControlState)state {
|
| switch (state) {
|
| @@ -39,11 +44,27 @@ - (void)setTintColor:(UIColor*)color forState:(UIControlState)state {
|
| [self updateTint];
|
| }
|
|
|
| +- (void)setBackgroundColor:(UIColor*)color forState:(UIControlState)state {
|
| + switch (state) {
|
| + case UIControlStateNormal:
|
| + normalStateBackgroundColor_ = [color copy];
|
| + break;
|
| + case UIControlStateHighlighted:
|
| + highlightedBackgroundColor_ = [color copy];
|
| + break;
|
| + default:
|
| + return;
|
| + }
|
| +
|
| + [self updateBackgroundColor];
|
| +}
|
| +
|
| #pragma mark - UIControl
|
|
|
| - (void)setHighlighted:(BOOL)highlighted {
|
| [super setHighlighted:highlighted];
|
| [self updateTint];
|
| + [self updateBackgroundColor];
|
| }
|
|
|
| #pragma mark - Private
|
| @@ -64,4 +85,20 @@ - (void)updateTint {
|
| self.tintColor = newTint;
|
| }
|
|
|
| +- (void)updateBackgroundColor {
|
| + UIColor* newBackgroundColor = nil;
|
| + switch (self.state) {
|
| + case UIControlStateNormal:
|
| + newBackgroundColor = normalStateBackgroundColor_;
|
| + break;
|
| + case UIControlStateHighlighted:
|
| + newBackgroundColor = highlightedBackgroundColor_;
|
| + break;
|
| + default:
|
| + newBackgroundColor = normalStateBackgroundColor_;
|
| + break;
|
| + }
|
| + self.backgroundColor = newBackgroundColor;
|
| +}
|
| +
|
| @end
|
|
|