動畫
UIKit
動畫用于交互設(shè)計:
更好的展示:relationship蝇率,structure考润,cause & effect
UIView提供的動畫支持
(UIViewAnimation): depricated
UIView(UIViewAnimationWithBlocks)
+(void)animateWithDuration:(NSTimeInterval) delay:(NSTimeInterval) options:(UIViewAnimationOptions) animations:(void (^)(void)) completion:(void(^ _nullable)(BOOL finished));
+(void)animateWithDuration:(NSTimeInterval) animations:(void (^)(void)) completion:(void(^ _nullable)(BOOL finished))
+(void)animateWithDuration:(NSTimeInterval) animations:(void (^)(void))
Autolayout 環(huán)境下的動畫
修改 constraint
-[view setNeedsUpdateConstraints]
-[view layoutIfNeeded] in animation block
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut]設(shè)置動畫曲線,動畫曲線指定的是動畫進入和退出的方式,它也有幾個常量:
UIViewAnimationCurveEaseInOut
UIViewAnimationCurveEaseIn
UIViewAnimationCurveEaseOut
UIViewAnimationCurveLinear
setAnimationTransition:forView:cache:方法第一個參數(shù)定義動畫類型,第二個參數(shù)是當前視圖對象,第三個參數(shù)上使用緩沖區(qū)。
View Transition
切換動畫:用動畫過程提示已經(jīng)切換到新界面了蓬蝶。
UIView具有一個UIViewAnimationTransition屬性可以設(shè)定動畫,這些動畫是iOS提供幾個常用動畫有:
UIViewAnimationTransitionNone
UIViewAnimationTransitionFlipFromLeft
UIViewAnimationTransitionFlipFromRight
UIViewAnimationTransitionCurlUp
UIViewAnimationTransitionCurlDown
修改子視圖顯示時:
視圖替換:
1.從 fromView 切換到toView
2.一般是場景切換尘分,變化較大
CoreAnimation
Core Animation負責所有的滾動、旋轉(zhuǎn)丸氛、縮小和放大以及所有的iOS動畫效果培愁。其中UIKit類通常都有animated:參數(shù)部分,它可以允許是否使用動畫。
Core Animation還與Quartz緊密結(jié)合在一起,每個UIView都關(guān)聯(lián)到一個CALayer對象,CALayer是Core Animation中的圖層缓窜。
Core Animation創(chuàng)建動畫時候會修改CALayer屬性,然后讓這些屬性流暢地變化定续。Core Animation相關(guān)知識點:
圖層,圖層是動畫發(fā)生的地方,CALayer總是與UIView關(guān)聯(lián),通過layer屬性訪問。
隱式動畫,這是一種最簡單的動畫,不用設(shè)置定時器,不用考慮線程或者重畫雹洗。
Core Animation 認為動畫總是需要的,所以默認開著卧波;修改layer的可動畫屬性時时肿,會自動觸發(fā)動畫。
顯式動畫,是一種使用CABasicAnimation創(chuàng)建的動畫,通過CABasicAnimation,可以更明確地定義屬性如何改變動畫港粱。
關(guān)鍵幀動畫,這是一種更復(fù)雜的顯式動畫類型,這里可以定義動畫的起點和終點,還可以定義某些幀之間的動畫螃成。
網(wǎng)絡(luò)編程
原生API
TCP/IP簡介
HTTP協(xié)議簡介
REST
服務(wù)端API設(shè)計模式:使用Path指示資源旦签;HTTP Verb表達操作。
API方法冪等( Idempotence)的概念:執(zhí)行多次與執(zhí)行一次效果一樣寸宏。
AFNetWorking
https://github.com/AFNetworking/AFNetworking
安裝:
CocoaPods:Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'AFNetworking', '~> 3.0'
Carthage:Cartfile
github "AFNetworking/AFNetworking" ~>3.0
Get方法請求
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Post請求
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
AFNetworking 默認接受的數(shù)據(jù)類型是(在AFJSONResponseSerializer下):
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];