iOS开发学习之UI篇3、UILabel
2016-01-05 20:03
351 查看
// label 标签, 它主要的作用是用来呈现文字内容 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 每次创建工程必须写的4句代码 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [self.window setRootViewController:[[UIViewController alloc] init]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; #pragma mark - UILabel-标签 // label 标签, 它主要的作用是用来呈现文字内容,如果UIView子类有自己的初始化方法,就是用自己的,没有就使用父类的。 UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 200, 100)]; // 为label设置背景颜色 [myLabel setBackgroundColor:[UIColor lightGrayColor]]; [self.window addSubview:myLabel]; // 为label添加文字内容 myLabel.text = @"Press this button to start the engine"; // 设置label的显示行数 前提是高度得够。当行数设置为0的时候,文字会根据当前的高度自动换行 myLabel.numberOfLines = 0; // 设置文字颜色 myLabel.textColor = [UIColor yellowColor]; // 设置字体大小 NSLog(@"%@",myLabel.font); myLabel.font = [UIFont systemFontOfSize:10]; // 得到系统提供的所有字体类型 NSLog(@"%@",[UIFont familyNames]); // 设置字体类型 myLabel.font = [UIFont fontWithName:@"Zapfino" size:10]; // 设置label的折行方式 中间省略方式 myLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; // 根据字符折行 myLabel.lineBreakMode =NSLineBreakByCharWrapping; // 设置文在对齐方式 myLabel.textAlignment = NSTextAlignmentCenter; // 设置阴影颜色 myLabel.shadowColor = [UIColor blueColor]; // 设置阴影大小 myLabel.shadowOffset = CGSizeMake(2, 1); #pragma mark - UIImageView-显示图片 // 显示图片的控件 相框 UIImageView *myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height)]; [self.window addSubview:myImageView]; // 得到资源图片 (以下为自己导入一个图片) UIImage *myImage = [UIImage imageNamed:@"ugly.jpg"]; // 将图片添加到相框中 myImageView.image = myImage; return YES; }
相关文章推荐
- leetcode第一刷_Unique Paths
- 优化UITableViewCell高度计算的那些事 附源码
- (转载)iOS UILabel自定义行间距时获取高度
- IOS(UI)_UIButton(按钮)和UIImageView(图片按钮)
- iOS开发学习之UI篇 1、UIView
- IOS(UI)_UILabel(标签)
- UE 无法初始化FTP组件
- 有value时,li元素序列号就是value值,没有value,则会递增
- 关于百度 UEditor的使用
- Android can only be built by versions 3.81 and 3.82
- Arduino 中断和定时器
- lintcode :implement queue by two stacks 用栈实现队列
- UIAlertController
- UIView设置指定的border
- 给UIView 的子类们 UIButton UILbel等 。。。。加一个虚线圆角的border
- wifi模块ESP8266_AT arduino 库文件部分方法解析及优化
- iOS中xcode的调试技巧(打印UI层次、po)
- 项目文件包含 ToolsVersion="12.0" 设置,而此版本的 MSBuild 不支持该工具版本
- easyUI——easyui-textbox输入框绑定blur事件
- [iOS-UI]点击清空按钮,却会有提交的感觉