Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MWMLocationButtonStatusLabel.m « LocationButton « MapViewControls « CustomViews « Classes « Maps « iphone - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 273e7213173883073c2bbaf97f2931a56e1e7eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
//  MWMLocationButtonStatusLabel.m
//  Maps
//
//  Created by Ilya Grechuhin on 29.05.15.
//  Copyright (c) 2015 MapsWithMe. All rights reserved.
//

#import "MWMLocationButtonStatusLabel.h"
#import "MWMMapViewControlsCommon.h"
#import "UIKitCategories.h"

@implementation MWMLocationButtonStatusLabel

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
  self = [super initWithCoder:aDecoder];
  if (!self)
    return nil;
  self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  return self;
}

- (void)layoutSubviews
{
  static CGFloat const maxLabelWidthPercentOfScreen = 0.52;
  static CGFloat const hSpacing = 4.0;
  static CGFloat const vSpacing = 1.0;

  [super layoutSubviews];
  self.width = maxLabelWidthPercentOfScreen * self.superview.width;
  [self sizeToFit];
  self.width = self.width + 2.0 * hSpacing;
  self.height = self.height + 2.0 * vSpacing;
  self.midX = self.superview.midX;
  self.maxY = self.superview.height - 2.0 * kViewControlsOffsetToBounds;
}

- (void)show
{
  self.hidden = NO;
  self.alpha = 0.0;
  [UIView animateWithDuration:framesDuration(1) animations:^
  {
    self.alpha = 1.0;
  }
  completion:^(BOOL finished)
  {
    [self performSelector:@selector(hide) withObject:self afterDelay:framesDuration(30)];
  }];
}

- (void)hide
{
  [UIView animateWithDuration:framesDuration(1) animations:^
  {
    self.alpha = 0.0;
  }
  completion:^(BOOL finished)
  {
    self.hidden = YES;
  }];
}

@end