下面的代碼會在uiimageview上拍攝圖片和顯示。 pitcure可以填滿整個視野。如何使圖像顯得更小,以便保存的圖像不是全部屏幕。我希望在那裏拍攝照片的邊框。一個矩形邊框。謝謝。如何更改圖像選取器控制器中的圖像大小
@IBAction func Camera(_ sender: AnyObject) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.camera;
imagePicker.allowsEditing = false
self.present(imagePicker, animated: true, completion: nil)}}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject: AnyObject]!){
cameraScreen.image = image
self.dismiss(animated: true, completion: nil);
screenView = UIImageView()
screenView.frame = CGRect(x:0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
UIGraphicsBeginImageContext(self.cameraScreen.frame.size)
self.view.drawHierarchy(in: self.view.frame, afterScreenUpdates: true)
}
你想擴展您從圖像拾取完成處理得到的圖像? –