Day.02.24 UILabel

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    /*
     
        UILabel 文本标签
     */
    
    //1.创建
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 50, 300, 300)];
    
    //2.显示
    [self.view addSubview:label];
    
    //3.设置属性
    
        //①.文本内容
    label.text = @"hello world";
    
        //②.字体字号,
        //系统字体大小,系统默认是16
    label.font = [UIFont systemFontOfSize:26];
    
        //加粗字体大小
    label.font = [UIFont boldSystemFontOfSize:26];
    
        //查看所有字体
    NSLog(@"%@",[UIFont familyNames]);
    
        //指定字体和大小
    label.font = [UIFont fontWithName:@"Iowan Old Style" size:26];
    
        //③.字体颜色
    label.textColor = [UIColor redColor];
    
        //④.背景颜色
    label.backgroundColor = [UIColor greenColor];
    
        //⑤.显示位置:系统默认居左
    label.textAlignment = NSTextAlignmentCenter;//居中
    
//    label.textAlignment = NSTextAlignmentLeft;//居左
//    
//    label.textAlignment = NSTextAlignmentRight;//居右
    
        //⑥.设置行数:默认1行   0 = 自动匹配行数
    label.numberOfLines = 0;
    
        //⑦.尺寸自适应:自动根据文本的内容多少调整label的大小
    [label sizeToFit];
}
@end


2016-02-24 16:21:01.074 UILabel[1528:196043] (
    Copperplate,
    "Heiti SC",
    "Iowan Old Style",
    "Kohinoor Telugu",
    Thonburi,
    "Heiti TC",
    "Courier New",
    "Gill Sans",
    "Apple SD Gothic Neo",
    "Marker Felt",
    "Avenir Next Condensed",
    "Tamil Sangam MN",
    "Helvetica Neue",
    "Gurmukhi MN",
    "Times New Roman",
    Georgia,
    "Apple Color Emoji",
    "Arial Rounded MT Bold",
    Kailasa,
    "Kohinoor Devanagari",
    "Kohinoor Bangla",
    "Chalkboard SE",
    "Sinhala Sangam MN",
    "PingFang TC",
    "Gujarati Sangam MN",
    Damascus,
    Noteworthy,
    "Geeza Pro",
    Avenir,
    "Academy Engraved LET",
    Mishafi,
    Futura,
    Farah,
    "Kannada Sangam MN",
    "Arial Hebrew",
    Arial,
    "Party LET",
    Chalkduster,
    "Hoefler Text",
    Optima,
    Palatino,
    "Lao Sangam MN",
    "Malayalam Sangam MN",
    "Al Nile",
    "Bradley Hand",
    "PingFang HK",
    "Trebuchet MS",
    Helvetica,
    Courier,
    Cochin,
    "Hiragino Mincho ProN",
    "Devanagari Sangam MN",
    "Oriya Sangam MN",
    "Snell Roundhand",
    "Zapf Dingbats",
    "Bodoni 72",
    Verdana,
    "American Typewriter",
    "Avenir Next",
    Baskerville,
    "Khmer Sangam MN",
    Didot,
    "Savoye LET",
    "Bodoni Ornaments",
    Symbol,
    Menlo,
    "Bodoni 72 Smallcaps",
    Papyrus,
    "Hiragino Sans",
    "PingFang SC",
    "Euphemia UCAS",
    "Telugu Sangam MN",
    "Bangla Sangam MN",
    Zapfino,
    "Bodoni 72 Oldstyle"
)

system //系统
boldSystem //加粗字体
font //字体
size //大小
alignment //对齐
fit //合适
alpha //阿尔法  透明度

Day.02.24 UILabel_第1张图片
屏幕快照 2016-02-24 下午4.21.03.png

你可能感兴趣的:(Day.02.24 UILabel)