/**
UIImage 支持的文件類型(.tiff .jpg .png .gif .bmp .ico .cur .xbm)
UIImage 會在動在內存緊張時,清楚本類緩存的圖片資源(創建的對象本身不會消失),當程序再次執行該對象時,會重新加載!
*/
- (void)image{
UIImage *img ;
[UIImage imageNamed:@""];//有緩存
[UIImage imageWithContentsOfFile:@""];//加載指定文件名的圖片
/**
使用CIimage 返回UIimage
@param orientation 對圖片執行旋轉、鏡像等操作
*/
[UIImage imageWithCGImage:nil scale:0 orientation:nil];
//UIImage 定時加載多張圖片,提供了兩個方法
/**
animatedImageNamed:根據指定圖片數組的名字記載,例如:name為img,該方法會自動加載img0.png,img1.png,img2.png等
*/
// [UIImage animatedImageNamed:<#(nonnull NSString *)#> duration:<#(NSTimeInterval)#>]
/**
該方法使用叫簡單,方便NSArray存入的是UIimage的對象
*/
// [UIImage animatedImageWithImages:<#(nonnull NSArray<UIImage *> *)#> duration:<#(NSTimeInterval)#>]
}
/**
UIimage 的API已經能夠滿足,大部分的需求,但是要細化處理圖片,則要使用CGImageRef
*/
- (void)CGImage{
UIImage *img;
CGImageRef ciImg = [img CGImage];
}
- (void)Quart_2D{
// Quart_2D 的核心API的關鍵是CGcontentRef 的獲取 及相關聯方法的調用
//1、自定義UIView的對象,可以在drawRect 里面獲取
// CGContextRef ctx = UIGraphicsGetCurrentContext();
// 2、若不在drawRect方法下,則要自己去創建
UIGraphicsBeginImageContextWithOptions(CGSizeZero, NO, 1.0);
UIGraphicsBeginImageContext(CGSizeZero);
}
CGContextRef相關API詳解
此節只是簡單圖形的繪制,若要繪制復雜圖片需要使用CGPathRef,將在下節詳細給出