#import "AppDelegate.h"
@interface AppDelegate ()
//#define k常量名 @""
//宏定義的作用就是用內容替換變量名
#define kContant @"我改過的內容"
#define kLableX lable.frame.origin.x
//#define kScreenWith.h
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.windowmakeKeyAndVisible];
/*
*控件之間的繼承關係
UILable
UIImageView
*/
// UIView顯示一塊有顏色的視圖
UIView *view = [[UIViewalloc] init];
view.frame = CGRectMake(50,50, 200, 200);
[self.windowaddSubview:view];
// UILabel標籤控件,適合一些短的文本
// UILable繼承於UIView
// 把lable對象實例化任何對象都要實例化
UILabel *lable = [[UILabelalloc] init];
// 給lable設置frame
lable.frame = CGRectMake(150, 150, 200, 200);
// 給lable設置文本
lable.text = kContant;
// 給文本設置字體顏色
lable.textColor = [UIColorblueColor];
// 給lable設置對齊方法是
lable.textAlignment =NSTextAlignmentCenter;
// UIFont UIColor 都是一種類 用他們來創建類都需要實例化
lable.font = [UIFontsystemFontOfSize:36];
// 在加粗的時候同時設置字體大小
lable.font = [UIFontboldSystemFontOfSize:48];
// 在設置斜體的同時設置字體大寫
lable.font = [UIFontitalicSystemFontOfSize:36];
// 設置陰影偏移量
lable.shadowOffset = CGSizeMake(-1, 1);
// 設置陰影顏色
lable.shadowColor = [UIColorredColor];
// 給類容設置行數 0代表自適應行數,非0是幾行就是幾行
lable.numberOfLines = 1;
// 自適應字體從而讓內容儘量顯示一行
lable.adjustsFontSizeToFitWidth =YES;
lable.backgroundColor = [UIColoryellowColor];
// 要把創建的視圖放在父視圖上面
[self.windowaddSubview:lable];
// UIImageView 用來顯示圖片
UIImageView *imView = [[UIImageViewalloc] init];
// 如果圖片名是png格式的圖片名不需要加格式,否則需要加
// imView.image = [UIImage imageNamed:@"1.tiff"];
imView.frame = CGRectMake(80, 100, 300, 300);
[self.windowaddSubview:imView];
// 創建幀動畫四要素
// 1.設置間隔時間
// 2.準備圖片素材
// 3.設置重複次數
// 4.開始動畫
// animationDuration 設置動畫的時間間隔
imView.animationDuration =1;
// animationImages 重獲動畫
UIImage *img1 = [UIImageimageNamed:@"1.tiff"];
UIImage *img2 = [UIImageimageNamed:@"2.tiff"];
UIImage *img3 = [UIImageimageNamed:@"3.tiff"];
UIImage *img4 = [UIImageimageNamed:@"4.tiff"];
NSArray *array = @[img1,img2,img3,img4];
// 給幀動畫準備素材
imView.animationImages = array;
// 給動畫設置重複次數使用0無限次循環
// NSNotFound 無限大
imView.animationRepeatCount =NSNotFound;
// 動畫開始
// 在某個方向上讓圖片自動適應已達到最好看的效果
imView.contentMode =UIViewContentModeScaleAspectFill;
//
imView.contentMode =
UIViewContentModeScaleToFill;
[imView startAnimating];
// 結束
// [imView stopAnimating];
// 延遲多少秒後執行響應的方法
// 用selector聲明的方法一定要實現,否則會奔潰
[selfperformSelector:@selector(start)withObject:nilafterDelay:5];
// 宏定義
// UIScreen指的是屏幕,能幫助我們獲取到各種屏幕的寬和高
NSLog(@"%f",[UIScreenmainScreen].bounds.size.height);
return YES;
}
- (void)start{
}