s140

Swiftに関するメモ

画像の読み込み、拡大縮小(UIImage)

 

import UIKit

let myImage:UIImage = UIImage(named: "x.jpg")!

let mySize:CGSize = CGSize(width: 500.0, height: 500.0)

UIGraphicsBeginImageContextWithOptions(mySize, false, 1.0)

myImage.draw(in: CGRect(x: 0.0, y: 0.0, width: 500.0, height: 500.0))

let myContext:UIImage = UIGraphicsGetImageFromCurrentImageContext()!

UIGraphicsEndImageContext()

 f:id:s140:20190106043332p:plain