初识IOS,Label控件的应用。
// // ViewController.m // Gua.test // // Created by 郭美男 on 16/5/31. // Copyright © 2016年 西瓜大人. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController /* * create label function * */ - (void) uiLabel { //分配内存并初始化对象 //[[UILabel alloc] init] //alloc 分配内存 //init 初始化 UILabel* label = [[UILabel alloc] init]; label.text = @"hi,我是西瓜大人"; //X,Y,长,宽 label.frame = CGRectMake(120, 280, 160, 100); //控件背景色 label.backgroundColor = [UIColor clearColor]; //self.view.backgroundColor=[UIColor darkGrayColor]; //增加至主窗体 [self.view addSubview:label]; //控件背景色 label.backgroundColor = [UIColor darkGrayColor]; //控件字体大小 label.font = [UIFont systemFontOfSize:18]; //控件内字体是否偏移 label.shadowOffset = CGSizeMake(2, 2); label.shadowColor = [UIColor grayColor]; //控件内文字label内位置,默认居左。 label.textAlignment = NSTextAlignmentCenter; //控件内显示字体行数,0则为自动换行 label.numberOfLines = 0; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSLog(@"this is one ios project"); [self uiLabel]; [self uiButton]; //self.view.backgroundColor = [UIColor blueColor]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end