UILabel

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc
{
    // 对应属性里边那个strong(retain)
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor cyanColor];
    [self.window makeKeyAndVisible];
    [_window release];

    // UILabel(标签) 是显示文本(在视图上显示文字)的控件 在App中是出现频率最高的控件
    // 它是UIView的子类,扩展了文字显示的功能,它是能显示文字的视图
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    label.backgroundColor = [UIColor orangeColor];
    [self.window addSubview:label];
    [label release];

    // 设置文本内容
    label.text = @"天山童姥afgaj";
    // 文本内容的颜色
    label.textColor = [UIColor blackColor];
    // 文本的对齐方式
    label.textAlignment = NSTextAlignmentCenter;
    // 文本字体大小 font
    label.font = [UIFont systemFontOfSize:30];
    label.font = [UIFont fontWithName:@"Helvetica-Bold" size:30];   // 黑体加粗

    // 文本行数
    // 设置行数 默认是一行,设置几行就是显示几行,注意label的高度要能容纳行数
    // 如果行数没能显示完信息,没显示的信息以省略号代替
    // 设置成0是行数的最大值
    label.numberOfLines = 0;

    // 文本换行模式 以单词为单位换行
    // 让文本自己去适应label的尺寸,显示全部内容
    // 断行模式
    label.lineBreakMode = NSLineBreakByTruncatingMiddle;

    // 文本阴影
    // 阴影颜色
//    label.shadowColor = [UIColor redColor];
    // 阴影大小 阴影向x正方向偏移2,向y正方向偏移10.
//    label.shadowOffset = CGSizeMake(2, 10);

    // 设置圆角和边框
    label.layer.borderWidth = 1;
    // 幅度
    label.layer.cornerRadius = 10;
    label.layer.masksToBounds = YES;
    label.frame = CGRectMake(100, 100, 200, 200);
    // center可以修改视图的位置
    label.center = CGPointMake(100+75, 100+75);

    return YES;
}

@end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值