Is there any way to change the cropRect size for UIImagePickerController when using:
imagePickerController.allowsEditing = YES;
I want to set my own width and height depending on the image.
I was faced with that issue a while back and at the time there was no way of changing it (I'm pretty sure there still isn't).
I ended up creating my own cropping library. If I'm not mistaken I made use of SSPhotoCropper as a reference.
Related
I’m trying to make simple meme app using Swift.I need to set up image at full screen.You can see Main StoryBoard with constraints here. But when im picking image that must fill full screen in portrait as result there is blank spaces in top and bottom. Similarly with landscape image but now spaces are on right and left. Anyone know how to fix this?
Set your UIImageView's contentMode to aspectFill.
Either in the storyboard…
or in code…
imageView.contentMode = .aspectFill
You can also implement a very handy third party library, easy to use : https://github.com/JanGorman/Agrume
It enables you to handle every kind of gestures, interactions, zooms etc.. on your UIImageView.
Thus, you won't have to worry about portrait/landscape constraints.
#Ashley Mills answer is the answer, mine is just an advice.
A am using the brilliant StackBlur class with in my project which works fine however I am trying to create a similar effect to the Yahoo Weather App in which the image blurs according to the scroll value. I have managed to achieve it using the scrollViewDidScroll method however the effect is slow and laggy.
What is the best way yo resolve this? Storing the image to the Cache is the only thing I can think of.
Thanks
UPDATE
I simply created two UIImageViews one with the blur and then set the alpha to zero and increased it with the content offset off the scrollview.
You don't need to blur every time when scrollViewDidScroll called. Instead, you need a blurred imageView with the final blur effect and none blurred imageView placed below the blurred one. Change view.alpha of blurred imageView from 0.0 to 1.0 will get this effect without extra cost.
Try DKLiveBlur to show live effect of yahoo blur.
I have a QR/bar code reader app that uses the ZBar SDK. I want to implement a custom overlay and remove everything else so the camera view covers the entire screen. The overlay is not difficult to implement. When I remove the ZBar controls via reader.showsZBarControls = NO; it removes the controls but leaves a black bar on the bottom of the screen, instead of filling the whole screen with the camera view, which is what I want.
I have tried using reader.wantsFullScreenLayout = YES; and reader.showsCameraControls = NO; without any luck. Has anyone done anything similar or have any suggestions?
For future reference it was as simple as changing the size of the UIView in the reader, as such:
CGRect frame = reader.readerView.frame;
frame.size.height += 55;
reader.readerView.frame = frame;
Maybe it can help someone
Cudos to #iAmbitious for the help
Recently I have observed some strange behaviour with the UIImageView and am wondering if anyone can provide some insite. I have two UIImageViews with the images inside them being loaded from a database. Inside the Xcode inspector I set the clip subview property and change the image mode to aspect fill. This works fine, when the images are loaded they appear correctly in their views and are clipped as they should be. However, I wanted to add a place holder image incase the user hadn't uploaded one yet. When I did this it the image was not resized and and stretched passed its view. I tried to reset the properties programatically as can be seen below, but nothing changed.
//code used to try to reset the image mode and clipping of the sub-views
//set up user profile picture
_profilePic.contentMode = UIViewContentModeScaleAspectFit;
_profilePic.layer.masksToBounds = YES;
_profilePic.layer.borderColor = [UIColor whiteColor].CGColor;
_profilePic.layer.borderWidth = 3.0f;
//set up users cover photo
_coverPhoto.contentMode = UIViewContentModeScaleAspectFit;
_coverPhoto.clipsToBounds = YES;
_coverPhoto.layer.masksToBounds = YES;
Why is this happening when I add an image to the view through the Xcode inspector but not when the image is left empty?
You should use UIViewContentModeScaleAspectFill instead of UIViewContentModeScaleAspectFit.
When I add them with the following line of code at the beginning of ViewDidLoad I get the same effect and have none of the unwanted image overflow.
_coverPhoto.image = [UIImage imageNamed:#"stockCoverPhoto.png"];
_profilePic.image = [UIImage imageNamed:#"stockProfilePhoto.png"];
Not the most informative solution, as it provides no insight into this issue but it is a solution. Anyone have any other input on how to fix this issue, why it even happens I would love to hear it as im still scratching my head.
Same on here.. No way to change contentMode after setImage to UIImageView..
I have a very simple situation: in a view i have an UIImageView and one UILabel. at a moment in time I want to change the position of the label and in the same method to change the image of the uiimageview.
self.myLabel.center = CGPointMake(158, 230);
self.myImageView.image = [UIImage imageNamed:#"anotherImage.png"];
But this code will change only the image and will not move the label. If i comment out the second line and run the code then the label will change the position.
Dose anybody have an idea why is not working? Or a valid workaround for this problem?
I just tested the above code and it works fine. When the keyboard pops up, label moves and image changes fine. The issue in your program has to be something simple, but it isn't the above code.
Now that we've got iOS6, whenever I see posts about changes to frame coordinates not seeming to behave properly when done via code, I immediately suspect the Autolayout settings:
Make sure you uncheck that, because otherwise constraint based logic will override any attempts to manually adjust settings via code. (Or, if you want to use Autolayout, rather than setting frame coordinates, programmatically adjust your constraints to achieve the desired result.)
Anyway, it sounds like that was you issue. Glad you solved it!