I have a UIImageView with a UIImage I set directly in the Storyboard/IB. I've also selected the Scale to Fill Mode
And this is what it looks like in IB/Storyboard:
However when I run the app it looks like this:
Any ideas on how I could fix this? I've tried changing mode in the storyboard/IB to say for example the center mode, this however just gives me a part of the image taken from the center of it.
Seems that I didn't connect constraints to all points. Doing so and making sure all constraint lines were blue solved it.
Related
Currently, I have a UIButton and want to set an image inside of it. I'm successfully able to set the image to inside the UIButton but for some reason, the image is VERY small compared to the UIButton. I want to increase the size of the image - no, not cover the entire button just a slight increase so it's a bit more visible on the UI.
More information, my UIButton is 40x40. The answers I've seen on StackOverFlow have indicated changing the Content Mode but even those answers have not helped. I'm a little stuck at this point so any expertise/advice would be highly appreciated!
Figured it out. I had to use image insets. This property allows to reposition the drawing rectangle for the button image. By setting values to the top, bottom, left, and right image insets we're creating a rectangle and thus, increasing the space for our image to be draw in.
I had actually seen this suggestion in other answers and had tried it but on IB, nothing seemed to change but I finally decided to test it on simulator and saw the affects.
I am creating a launch screen for my app, I have a picture in an Imageview that I want as a backdrop for a Label containing the title of the app.
Screenshot of the image in the background with Label in front of it
I was able to shift the Label to the front of the launchscreen.storyboard, so that it is on top of the Imageview, by changing their position in the viewcontroller index.like so
When I load the sim for the app, the image doesn't appear, so it ends up looking like this:
screenshot of launchscreen.storyboard
I haven't the foggiest ideas as to how to resolve this issue.
(Sidenote, I'm aware that nothing on the launchscreen.storyboard is aligned properly; I've removed all the constraints and I've been moving the moving things around in an effort to figure things out)
Is there something I need to drop into the Viewcontroller to make this happen?
I'm kind of at a loss..
Set the constraints to the image view to 0 for top-left-bottom-right. For the label, set the constraints to the top, center it to the page, and then set the size you want it to be. Sometimes when you change auto layout a lot within Xcode it gets buggy. You may want to delete all constraints and start fresh.
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.
This issue is really frustrating and getting me crazy.
I've read everything about AutoLayout and so on, but it happens all the time.
My interface has a view with an image view as background and a smaller subview on top of it (corresponding to a field in my image). I've tried everything but it looks like the subview does not scale accordingly with my image when switching through devices.
By the way, the IB preview does not show what i real get when running the iOS Simulator, is that normal?
Why? What do i do wrong? I'm not sure what else to try!
http://i58.tinypic.com/34xqtc6.png
EDIT: i cannot post images :(
I have setup a githubrepo regarding your case, kindly have a look
https://github.com/usamaiqbal83/TestingProject
Constraints for Background Image View:
Constraints for Front View
the most important thing to remember is ofcourse the constraint equation
FirstItem.Attribute1 = (SecondItem.Attribute2 * Multiplier) + Constant
Instead of subview use Container View.
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!