UIImage 是 iOS 中處理圖片的核心類別。常見操作包括從檔案或資料建立圖片、取得圖片尺寸、繪製、縮放與建立動畫圖。
drawAtPoint: 會在指定座標繪製圖片;drawInRect: 則可將圖片繪製到指定矩形,常用於縮放。若需要保留九宮格邊角,可使用 resizableImageWithCapInsets: 或 stretchableImageWithLeftCapWidth:topCapHeight:。
size、scale、imageOrientation、CGImage、CIImage 等屬性,可協助判斷圖片尺寸、方向與底層影像型別。動畫圖片則可透過 animatedImageNamed:duration: 或 animatedImageWithImages:duration: 建立。