iOS新手入门之UILable
2015-10-07 11:06
399 查看
UILable可以在上面显示字体
Xcode6.0之后 UILable添加到另外一个UILable上时 如果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]; // 创建一个UILable UILabel *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上没有文本 那么前者就显示不出来
相关文章推荐
- 深入Java集合学习系列:SynchronousQueue实现原理
- 深入Java集合学习系列:ArrayBlockingQueue及其实现原理
- 深入Java集合学习系列:ConcurrentLinkedQueue及其实现原理
- StringBuffer和StringBuilder
- 使用NGUI实现拖拽功能(拼图小游戏)
- iOS新手入门之UIView
- easyUI tootip组件使用
- Duilib中的消息泵和虚拟窗口
- 版本库重新定位时svn uuid不一致问题
- UI_UITableViewController
- String,StringBuffer与StringBuilder的区别
- UIScrollView
- UI:多线程 、用GCD创建线程
- Ubuntu14.04启动出现grub rescue
- AbstractQueuedSynchronizer的介绍和原理分析
- easyui反选全选和全不选代码以及方法的使用
- easyUI resizable组件使用
- [225]Implement Stack using Queues
- SpriteBuilder中CCB精灵对象的Sprite frame为什么有时候不能修改
- SpriteBuilder中CCB精灵对象的Sprite frame为什么有时候不能修改