iOS开发之基础视图——UILabel





//
//  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


     效果图如下:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值