#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
//label标签,它主要的作用是用来呈现文字内容,如果UIView子类有自己的初始化方法,就是用自己的,没有就是用父类的。
//初始化并创建一个label
UILabel *myLabel = [[UILabelalloc]initWithFrame:CGRectMake(100,100, 100, 100)];
//为label设置背景颜色
[myLabel setBackgroundColor:[UIColorredColor]];
//为label添加文字内容
myLabel.text = @"哈哈";
//显示label在页面上
[self.windowaddSubview:myLabel];
//设置label的显示行数前提是高度得够。
//当行数设置为0的时候,文字会根据当前的高度自动换行。
myLabel.numberOfLines = 2;
//设置文字颜色
myLabel.textColor = [UIColorgreenColor];
NSLog(@"字体大小%@",myLabel.font);
//设置字体大小
myLabel.font =[UIFontsystemFontOfSize:18];
//得到系统提供的所有字体类型
NSArray *fonts = [UIFontfamilyNames];
NSLog(@"字体%@",fonts);
//设置字体类型和大小
myLabel.font = [UIFontfontWithName:@"Zapfino"size:10];
//设置label的拆行方式
myLabel.lineBreakMode =NSLineBreakByTruncatingMiddle;
//设置文字的对齐方式(枚举类)
myLabel.textAlignment =NSTextAlignmentCenter;
//设置阴影颜色
myLabel.shadowColor = [UIColorblackColor];
//设置阴影大小
myLabel.shadowOffset =CGSizeMake(5,5);
//------------------------------------------------------------
//显示图片的控件相框
UIImageView *myImageView = [[UIImageViewalloc]initWithFrame:[UIScreenmainScreen].bounds];
[self.windowaddSubview:myImageView];
//得到资源图片
UIImage *myImage = [UIImageimageNamed:@"han.jpg"];
//将图片添加到相框中
myImageView.image = myImage;
//换层
[self.windowexchangeSubviewAtIndex:0withSubviewAtIndex:1];
self.window.backgroundColor = [UIColorwhiteColor];
[self.windowmakeKeyAndVisible];
return YES;
}