#import "AppDelegate.h"app
@interface AppDelegate ()ide
@end ui
@implementation AppDelegatethis
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {spa
// Override point for customization after application launch..net
_window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];3d
[_window setBackgroundColor:[UIColor whiteColor]];rest
//==============UIImageView=================orm
//UIImageView:UIView UIView的全部屬性方法UIImageView都擁有對象
//UIImageView專門用來顯示圖片的控件
//1.建立一個UIImageView對象
UIImageView *imageView = [[UIImageView alloc]
initWithFrame:CGRectMake(50, 50, 200, 200)];
//2.設置背景顏色
imageView.backgroundColor = [UIColor cyanColor];
//3.顯示在界面上;
[_window addSubview:imageView];
//UIIamge圖片類
//根據圖片名建立圖片(前提是圖片已經添加到工程中)
//拖到工程中的圖片實質是在當前這個應用程序的安裝包裏面;
//參數:圖片的名字(若是圖片是png圖片,圖片的後綴名能夠省略,其餘圖片後綴必須加上);
UIImage *image1 = [UIImage imageNamed:@"back2.jpg"];
//根據文件路徑來建立圖片;
//參數是圖片文件的路徑;拿到包中圖片的路徑;(能夠拿到當前工程中任何文件的路徑)
//參數一:文件的名字
//參數二:文件的後綴
NSString *path = [[NSBundle mainBundle] pathForResource:
@"player_down_1" ofType:@"png"];
UIImage *image2 = [UIImage imageWithContentsOfFile:path];
//==========獲取圖片的大小==============
CGSize imageSize = image1.size;
//NSLog(@"%@",NSStringFromCGSize(imageSize));
//兩種建立圖片方式的區別:
//1.經過圖片名直接建立:代碼簡單,imageNamed建立的圖片的聲明語法是整個工程結束,
//並且若是是同一張圖片建立的image對象是惟一的.
//2.經過圖片文件的路徑來建立圖片
//4.設置圖片(核心屬性)
[imageView setImage:image1];
//5.設置內容模式
// typedef NS_ENUM(NSInteger, UIViewContentMode) {
// UIViewContentModeScaleToFill,
//(默認的模式:將圖片進行縮放將圖片整個顯示在imageView上;
// UIViewContentModeScaleAspectFit,//將圖片按照比例縮放完整顯示在imageView上
// UIViewContentModeScaleAspectFill,//圖片和imageView都按圖片的比例縮放
// UIViewContentModeRedraw,
// UIViewContentModeCenter,//完整的將圖片中間的顯示出來
// UIViewContentModeTop,
// UIViewContentModeBottom,
// UIViewContentModeLeft,
// UIViewContentModeRight,
// UIViewContentModeTopLeft,
// UIViewContentModeTopRight,
// UIViewContentModeBottomLeft,
// UIViewContentModeBottomRight,
// };
[imageView setContentMode:UIViewContentModeScaleToFill];
[_window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end