Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: ios/chrome/browser/ui/fancy_ui/tinted_button.mm

Issue 2934463002: [iOS] Add experimental new keyboard accessory view. (Closed)
Patch Set: Rebased. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/chrome/browser/ui/fancy_ui/tinted_button.h ('k') | ios/chrome/browser/ui/toolbar/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/browser/ui/fancy_ui/tinted_button.h"
6
7 #if !defined(__has_feature) || !__has_feature(objc_arc)
8 #error "This file requires ARC support."
9 #endif
10
11 @interface TintedButton () {
12 UIColor* normalStateTint_;
13 UIColor* highlightedTint_;
14 }
15
16 // Makes the button's tint color reflect its current state.
17 - (void)updateTint;
18
19 @end
20
21 @implementation TintedButton
22
23 - (void)setTintColor:(UIColor*)color forState:(UIControlState)state {
24 switch (state) {
25 case UIControlStateNormal:
26 normalStateTint_ = [color copy];
27 break;
28 case UIControlStateHighlighted:
29 highlightedTint_ = [color copy];
30 break;
31 default:
32 return;
33 }
34
35 if (normalStateTint_ || highlightedTint_)
36 self.adjustsImageWhenHighlighted = NO;
37 else
38 self.adjustsImageWhenHighlighted = YES;
39 [self updateTint];
40 }
41
42 #pragma mark - UIControl
43
44 - (void)setHighlighted:(BOOL)highlighted {
45 [super setHighlighted:highlighted];
46 [self updateTint];
47 }
48
49 #pragma mark - Private
50
51 - (void)updateTint {
52 UIColor* newTint = nil;
53 switch (self.state) {
54 case UIControlStateNormal:
55 newTint = normalStateTint_;
56 break;
57 case UIControlStateHighlighted:
58 newTint = highlightedTint_;
59 break;
60 default:
61 newTint = normalStateTint_;
62 break;
63 }
64 self.tintColor = newTint;
65 }
66
67 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/fancy_ui/tinted_button.h ('k') | ios/chrome/browser/ui/toolbar/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698