//
// AppDelegate.m
// UILabelDemo
//
// Created by Apple on 16/5/11.
// Copyright © 2016年 Apple. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//初始化一个窗口
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
//设置窗口的背景颜色为白色
self.window.backgroundColor = [UIColor whiteColor];
//初始化一个UIViewController视图控制器
UIViewController *vc = [[UIViewController alloc] init];
//设置上述视图控制器为窗口的根视图控制器
self.window.rootViewController = vc;
//初始化一个视图
UIView *view = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
//把上述视图设置为根视图控制器的视图
vc.view = view;
//创建一个UILabel对象
UILabel * label = [[UILabel alloc] init];
//设置UILabel的布局
label.frame = CGRectMake(100, 100, 100, 150);
//设置UILabel的文本
[label setText:@"好好学习天天向上1111111"];
//设置允许显示多少行
[label setNumberOfLines:3];
//把label添加到视图上面,这一步容易忘掉
[view addSubview:label];
[self.window makeKeyAndVisible];
return YES;
}
@end
效果图如下: