UILabel
2015-08-05 21:30
337 查看
#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
相关文章推荐
- UE4 Blueprint编译过程
- 用户名为空时UITextFild 抖动
- UE4暴露游戏元素给蓝图
- ContentValues的用法
- UE4编程快速入门
- iOS开发_UIView
- 用UIPagecontrol和UIScroller制作简易的相册(MRC状态下)
- UE4蓝图术语表
- Quartz2D - 04.利用贝瑟尔路径(UIBezierPath)绘制基本图形
- Windows/MFC_三个退出程序消息:WM_CLOSE、WM_DESTROY、WM_QUIT
- UE4蓝图用户指南
- UE4蓝图简介
- Rescue
- iOS之UIView的层次结构变更
- UIPickerView的简单应用——省份/城市选择的实现
- CSS3 Media Query:移动 Web 的完美开端
- 黑马程序员——break和continue语句+函数+函数重载-第4天
- 黑马程序员—JAVA基础—GUI(图形化界面编程)
- iOS之UIView的圆角
- UIView详解