编辑代码

var myString = "Hello world!     -  swift.jsrun.net"
print(myString)
import UIKit
class ViewController:
UIViewcontroller,
UINavigationControllerDelegate, UITmagePickerControllerDelegatef//设置因像显示用的 outlet,就是变量 car ImageView
@IBOutlet weak var
carlmageView:UllmageView!//设置 Action,由相册按钮事件触发@IBAction func onLibrary (_
sender:UlButton) [
//设置相册拍照的控制器
let vc =UllmagePickerController//设置为相册
vC.sourceType=.photoLibrary vc.allowsEditing = true
vc.delegate = self
present (vc, animated: true)
]
//设置 Action,由拍照按钮事件触发@IBAction func
oncamera( sender: UIButton) [let vc =UllmagePickerController ()//设置为摄像头
vc.sourceType =.camera
vc.allowsEditing = true
vc.delegate = self
present (vC, animated: true)
]
//相價获取圈片需要凋用的 Delegate func imagePickerController|_
picker:UllmagePickerController didFinishPickingMediawithlnfo info:(UI ImagePickerController. InfoKey: Any))
picker.dismiss(animated:true) guard let image = infol.
editedlmage\ as? UI lmage else f return
]
// 将相册图片显示在 carlmageview中
carlmageView.image=image
]
]