ios - Image to Initially Fill UIImagePickerController -
in ios app i'd grab images photo library , crop them square format. uiimagepickercontroller
takes care of nicely, there 1 little problem: when select landscape-oriented photo library not fill crop area (for portrait images does). allows user select non-square area. is there way force image picker fill crop area vertically horizontally - without implemeting own image picker?
my code:
class addprofileviewcontroller: uiviewcontroller, uigesturerecognizerdelegate, uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate { @iboutlet weak var profileimageview: enhancedimageview! let imagepicker = uiimagepickercontroller() override func viewdidload() { super.viewdidload() // ... imagepicker.delegate = self } func profileimagetapped() { imagepicker.allowsediting = true imagepicker.sourcetype = .photolibrary presentviewcontroller(imagepicker, animated: true, completion: nil) } func imagepickercontroller(picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [nsobject : anyobject]) { // ... } func imagepickercontrollerdidcancel(picker: uiimagepickercontroller) { dismissviewcontrolleranimated(true, completion: nil) } }
selecting landscape image, looks this:
instead, i'd image horizontally , vertically extend crop frame, image picker return square image.
to close question - here how solved it:
extending image vertically boundaries not seem possible standard image picker. options create own image picker or use following workaround might sufficient in cases:
if user not zoom in section of image center of image best approximation user wants, , square image cutting off equal-width slices on both sides.
Comments
Post a Comment