OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" | 5 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" |
6 | 6 |
7 #if !defined(__has_feature) || !__has_feature(objc_arc) | 7 #if !defined(__has_feature) || !__has_feature(objc_arc) |
8 #error "This file requires ARC support." | 8 #error "This file requires ARC support." |
9 #endif | 9 #endif |
10 | 10 |
11 namespace { | 11 namespace { |
| 12 const CGFloat kBorderMargin = 6.0f; |
12 const CGFloat kSelectedBorderCornerRadius = 8.0f; | 13 const CGFloat kSelectedBorderCornerRadius = 8.0f; |
13 const CGFloat kSelectedBorderWidth = 4.0f; | 14 const CGFloat kSelectedBorderWidth = 4.0f; |
14 } | 15 } |
15 | 16 |
16 @implementation TabCollectionTabCell | 17 @implementation TabCollectionTabCell |
17 | 18 |
18 - (instancetype)initWithFrame:(CGRect)frame { | 19 - (instancetype)initWithFrame:(CGRect)frame { |
19 if ((self = [super initWithFrame:frame])) { | 20 if ((self = [super initWithFrame:frame])) { |
20 self.selectedBackgroundView = [[UIView alloc] init]; | 21 [self setupSelectedBackgroundView]; |
21 self.selectedBackgroundView.backgroundColor = [UIColor blackColor]; | |
22 self.selectedBackgroundView.layer.cornerRadius = | |
23 kSelectedBorderCornerRadius; | |
24 self.selectedBackgroundView.layer.borderWidth = kSelectedBorderWidth; | |
25 self.selectedBackgroundView.layer.borderColor = self.tintColor.CGColor; | |
26 self.selectedBackgroundView.transform = CGAffineTransformScale( | |
27 self.selectedBackgroundView.transform, 1.08, 1.08); | |
28 } | 22 } |
29 return self; | 23 return self; |
30 } | 24 } |
31 | 25 |
| 26 - (void)setupSelectedBackgroundView { |
| 27 self.selectedBackgroundView = [[UIView alloc] init]; |
| 28 self.selectedBackgroundView.backgroundColor = [UIColor blackColor]; |
| 29 |
| 30 UIView* border = [[UIView alloc] init]; |
| 31 border.translatesAutoresizingMaskIntoConstraints = NO; |
| 32 border.backgroundColor = [UIColor blackColor]; |
| 33 border.layer.cornerRadius = kSelectedBorderCornerRadius; |
| 34 border.layer.borderWidth = kSelectedBorderWidth; |
| 35 border.layer.borderColor = self.tintColor.CGColor; |
| 36 [self.selectedBackgroundView addSubview:border]; |
| 37 [NSLayoutConstraint activateConstraints:@[ |
| 38 [border.topAnchor |
| 39 constraintEqualToAnchor:self.selectedBackgroundView.topAnchor |
| 40 constant:-kBorderMargin], |
| 41 [border.leadingAnchor |
| 42 constraintEqualToAnchor:self.selectedBackgroundView.leadingAnchor |
| 43 constant:-kBorderMargin], |
| 44 [border.trailingAnchor |
| 45 constraintEqualToAnchor:self.selectedBackgroundView.trailingAnchor |
| 46 constant:kBorderMargin], |
| 47 [border.bottomAnchor |
| 48 constraintEqualToAnchor:self.selectedBackgroundView.bottomAnchor |
| 49 constant:kBorderMargin] |
| 50 ]]; |
| 51 } |
| 52 |
32 @end | 53 @end |
OLD | NEW |