iOS新手入门之UILable

来源:互联网 发布:网络借贷怎么样 编辑:程序博客网 时间:2024/06/11 06:40

UILable可以在上面显示字体

#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (void)dealloc{    [_window release];    [super dealloc];}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];    self.window.backgroundColor = [UIColor grayColor];// 创建一个UILableUILabel *aLable = [[UILabel alloc] initWithFrame:(CGRectMake(100, 100, 200, 200))];// 给UILable添加背景颜色aLable.backgroundColor = [UIColor greenColor];// 在UILable上添加文本aLable.text = @"我叫王大锤";// 设置字体颜色aLable.textColor = [UIColor blueColor];// 设置文本是否居中aLable.textAlignment = NSTextAlignmentCenter;// 设置文本行数 如果行数设置为0 在lable足够大的情况下 可以把文本显示完整 自动换行aLable.numberOfLines = 0;// 设置字体大小aLable.font = [UIFont systemFontOfSize:30];// 下面两个不常用 几乎不用// 设置阴影aLable.shadowColor = [UIColor whiteColor];// 设置阴影位置aLable.shadowOffset = CGSizeMake(10, 10);// 把aLable显示出来 也就是添加到window上[self.window addSubview:aLable];// 释放lable[aLable release];}

Xcode6.0之后 UILable添加到另外一个UILable上时 如果UILable上没有文本 那么前者就显示不出来

0 0