bundle内のファイル一覧を取得
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
do {
let files = try FileManager().contentsOfDirectory(atPath: Bundle.main.bundlePath)
print(files)
} catch let error {
print(error)
}
}
}
画像の読み込み、拡大縮小(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()