OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/settings/bar_button_activity_indicator.h" |
| 6 |
| 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "ios/chrome/browser/ui/ui_util.h" |
| 9 |
| 10 @implementation BarButtonActivityIndicator { |
| 11 base::scoped_nsobject<UIActivityIndicatorView> activityIndicator_; |
| 12 } |
| 13 |
| 14 - (id)initWithFrame:(CGRect)frame { |
| 15 self = [super initWithFrame:frame]; |
| 16 if (self) { |
| 17 activityIndicator_.reset([[UIActivityIndicatorView alloc] |
| 18 initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]); |
| 19 [activityIndicator_ setBackgroundColor:[UIColor clearColor]]; |
| 20 [activityIndicator_ setHidesWhenStopped:YES]; |
| 21 [activityIndicator_ startAnimating]; |
| 22 [self addSubview:activityIndicator_]; |
| 23 } |
| 24 return self; |
| 25 } |
| 26 |
| 27 - (void)dealloc { |
| 28 [activityIndicator_ stopAnimating]; |
| 29 [super dealloc]; |
| 30 } |
| 31 |
| 32 - (void)layoutSubviews { |
| 33 [super layoutSubviews]; |
| 34 CGSize boundsSize = self.bounds.size; |
| 35 CGPoint center = CGPointMake(boundsSize.width / 2, boundsSize.height / 2); |
| 36 [activityIndicator_ setCenter:AlignPointToPixel(center)]; |
| 37 } |
| 38 |
| 39 @end |
OLD | NEW |