summaryrefslogtreecommitdiffstats
path: root/gn/examples/ios/app/ViewController.m
blob: e0a80cb728e0eaf285f5a923f8f4ca1418ddac8a (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
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <HelloShared/HelloShared.h>

#import "app/ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  UILabel* label = [self labelWithText:[Greetings greet]];
  [self addCenteredView:label toParentView:self.view];
}

- (UILabel*)labelWithText:(NSString*)text {
  UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero];
  label.text = text;
  [label sizeToFit];
  return label;
}

- (void)addCenteredView:(UIView*)view toParentView:(UIView*)parentView {
  view.center = [parentView convertPoint:parentView.center
                                fromView:parentView.superview];
  [parentView addSubview:view];
}

@end