16d528ed9Sopenharmony_ci// Copyright 2019 The Chromium Authors. All rights reserved. 26d528ed9Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 36d528ed9Sopenharmony_ci// found in the LICENSE file. 46d528ed9Sopenharmony_ci 56d528ed9Sopenharmony_ci#import <HelloShared/HelloShared.h> 66d528ed9Sopenharmony_ci 76d528ed9Sopenharmony_ci#import "app/ViewController.h" 86d528ed9Sopenharmony_ci 96d528ed9Sopenharmony_ci@implementation ViewController 106d528ed9Sopenharmony_ci 116d528ed9Sopenharmony_ci- (void)viewDidLoad { 126d528ed9Sopenharmony_ci [super viewDidLoad]; 136d528ed9Sopenharmony_ci 146d528ed9Sopenharmony_ci UILabel* label = [self labelWithText:[Greetings greet]]; 156d528ed9Sopenharmony_ci [self addCenteredView:label toParentView:self.view]; 166d528ed9Sopenharmony_ci} 176d528ed9Sopenharmony_ci 186d528ed9Sopenharmony_ci- (UILabel*)labelWithText:(NSString*)text { 196d528ed9Sopenharmony_ci UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero]; 206d528ed9Sopenharmony_ci label.text = text; 216d528ed9Sopenharmony_ci [label sizeToFit]; 226d528ed9Sopenharmony_ci return label; 236d528ed9Sopenharmony_ci} 246d528ed9Sopenharmony_ci 256d528ed9Sopenharmony_ci- (void)addCenteredView:(UIView*)view toParentView:(UIView*)parentView { 266d528ed9Sopenharmony_ci view.center = [parentView convertPoint:parentView.center 276d528ed9Sopenharmony_ci fromView:parentView.superview]; 286d528ed9Sopenharmony_ci [parentView addSubview:view]; 296d528ed9Sopenharmony_ci} 306d528ed9Sopenharmony_ci 316d528ed9Sopenharmony_ci@end 32