从article开始,我正在学习图片/从库中选择,并将结果放在UIImageView中。
@IBOutlet var theImage: UIImageView!;
@IBAction func openLibrary (sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.PhotoLibrary) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary;
imagePicker.allowsEditing = true
self.presentViewController(imagePicker, animated: true, completion: nil)
}
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
theImage.image = image;
self.dismissViewControllerAnimated(true, completion: nil);
}
结果如下:
像裁剪的图像,即使我已将模式设置为Aspect Fit。怎么了?
编辑:
缩放以适应?这就是我在图像模式中的全部内容: