以下代码在uiimageview上拍摄照片和显示。 pitcure填满了整个uiimageview。如何使图像显得更小,以便保存的图像不是整个屏幕。我想在拍摄的照片周围有一个边框。矩形边框。谢谢。
@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)
}
答案 0 :(得分:1)
这是一个必须在didFinishPickingImage完成处理程序中调用的方法。
<?php
$picture_container = simplexml_load_file('data.xml');
echo $picture_container->[month-name[0]]->[channel-name[1]]->title;
?>
此方法将改变图像的大小。
答案 1 :(得分:0)
更新了Kirti Parghi对Swift 3的回答
func resizeImage(image: UIImage, newWidth: CGFloat) -> UIImage? {
let scale = newWidth / image.size.width
let newHeight = image.size.height * scale
UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))
image.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: newHeight))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}