Objective-C (iOS): テキストを画面に表示

iOSシミュレータのスクリーンショット 2013.01.03 2.08.39

Objective-C: UILabelViewController.m

#import "UILabelViewController.h"

@interface UILabelViewController ()

@end

@implementation UILabelViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    label.text = @"ほげほげ";
    [self.view addSubview:label];
    
    UIFont *font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:26.0f];
    UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
    label2.text = @"hogehoge";
    label2.font = font;
    label2.textColor = [UIColor whiteColor];
    label2.backgroundColor = [UIColor redColor];
    label2.textAlignment = NSTextAlignmentRight;
    [self.view addSubview:label2];
}

@end