所有的UI控件都是UIView的子類
UIWindow
UIWindow是UIView的子類
1草则、創(chuàng)建和配置UIWindow
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
2贷洲、APPDelegate.m文件中各方法調(diào)用的情況
//開啟循環(huán)機(jī)制
//程序啟動完畢(創(chuàng)建UI控件存捺,)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {}
//應(yīng)用程序?qū)⒁M(jìn)入非活動狀態(tài)(將要失去焦點(diǎn)钉汗,例如移袍,來電)
- (void)applicationWillResignActive:(UIApplication *)application {}
//進(jìn)入后臺(保存數(shù)據(jù)爷绘,一定時間后會掛起)
- (void)applicationDidEnterBackground:(UIApplication *)application {}
//即將進(jìn)入前臺(恢復(fù)數(shù)據(jù))
- (void)applicationWillEnterForeground:(UIApplication *)application {}
//進(jìn)入活動狀態(tài)
- (void)applicationDidBecomeActive:(UIApplication *)application {}
//程序退出前調(diào)用,(保存數(shù)據(jù))
- (void)applicationWillTerminate:(UIApplication *)application {}
//內(nèi)存警告,當(dāng)應(yīng)用程序內(nèi)存過低時书劝,會發(fā)出警告(清除不常用的內(nèi)存,)
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{NSLog(@"內(nèi)存警告");}
UIView
1.創(chuàng)建UIView
//代碼創(chuàng)建
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0,0,100,100)];
//xib創(chuàng)建
UIView *view = [[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil][0];\
2.常用屬性
backgroundColor //背景色
subViews //子視圖
hidden //是否隱藏
tag //標(biāo)簽值
superview //父視圖
userInteractionEnabled //是否響應(yīng) 戶觸摸事件
clipsToBounds //是否裁剪其 視圖
3.常用方法
? insertSubview:atIndex: //視圖插入到制定索引位置
? insertSubview:aboveSubview: //視圖插 到指定視圖之上
? insertSubview:belowSubview: //視圖插 到指定視圖之下
? bringSubviewToFront: //視圖移動到最上層
? sendSubviewToBack: //視圖移動到最底層
? exchangeSubviewAtIndex:withSubviewAtIndex //把兩個索引對應(yīng)視圖交換位置
? removeFromSuperview //把視圖從 視圖中移除
? addSubview: //添加子視圖 addSubview時,會對視圖進(jìn) retain,需要及時釋放 removeFromSuperview時會對視圖進(jìn) 釋放
4.視圖的簡單動畫
1.開始動畫
+(void)beginAnimations:(NSString *)animationID context:(void *)context;
2.持續(xù)時間
+(void)setAnimationDuration:(NSTimeInterval)dur;
3.提交動畫
+(void)commitAnimations
基于block的簡單動畫效果實(shí)現(xiàn)
+ (void)animateWithDuration:(NSTimeInterval)duration animations: (void (^)(void))animations completion:(void (^)(BOOL finished))completion