0

I am using @1x,@2x,@3x images for my background in the cassettes folder. I have set the view mode to center because other modes didn't fit nearly as well. I like the way the background fits in all the device sizes but the iPhone 6 fit ended up shrunk down. I set the main view to green to I could see what was happening. It's centered of course but why was it sized down if I supplied an iPhone 6 background of 1334x750px?

grg
  • 5,023
  • 3
  • 34
  • 50
  • Are you using auto layout? What are your constraints? – Suragch Mar 02 '15 at 06:08
  • @SuragchThanks for replying. Yes, I'm using auto-layout. Here's a screen so you can better see my constraints. http://imgur.com/xucyWG1 . p.s. Looks like Stackoverflow is infested with down-voters. Far from the image I had before I joined. –  Mar 02 '15 at 06:49
  • I think you can still do that. Just layer those top images over what I said in my answer. – Suragch Mar 02 '15 at 07:00
  • Yes. The long time StackOverflow users are pretty strict in their question requirements. I burned though one account before I learned how to ask questions that didn't get tons of downvotes. I still get some, though. Don't worry too much about it. http://stackoverflow.com/help/how-to-ask gives some general advice. I'm not sure why yours was downvoted but you could improve it by adding the images directly to your question rather than providing a link. – Suragch Mar 02 '15 at 07:05

1 Answers1

0

I would use an image view. With Auto Layout you can pin all four sides to the edges.

enter image description here

These constraints should make it look ok on any device in portrait orientation.

enter image description here

It looks a little stretched in landscape orientation, though, so you might want a different image for that.

Here is another answer if you want more help with auto layout.

Community
  • 1
  • 1
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • Hmmm That's odd because I AM using an image view for that background. It's called "grid" in the screenshot. I have the constraints set up too. Was I doing it wrong? Yeah I am making the game portrait only so the stretching won't be an issue. Why is your leading/trailing set to -16? And Xcode presents me with 1x,2x,3x containers when I click on that grid image set. Is that good or bad in my case? p.s. what did you use to create the row of images? It looks good. Oh also I tried to post images but it said I couldn't because my rep is less than 15. –  Mar 02 '15 at 07:19
  • I can't tell if your constraints are set up right or not. If I were you I would either delete all the constraints and start over or try it again in a test project. The -16 is because "Constrain to margins" was still checked and the margins were 16. I could uncheck that and then set them all to zero. It is the same thing. If you copy the 1/2/3x files all into your project and then select the name for the image ios does all the work of choosing which resolution to use for each device. I just used a single screenshot of your image, not a row of images. (I forgot new users can't post. Here is +1) – Suragch Mar 02 '15 at 08:50
  • Oh, I just realized what you meant by a row of images. Assistant Editor > Preview > Main.storyboard. Then press the "+" button to add previews for different device sizes. – Suragch Mar 02 '15 at 08:55
  • Hi thanks for the +1. I guess you have a 27" to fit all those previews on one screen ;) I'm pretty comfortable with all of Xcode's storyboarding and layout features so I'm not sure why it's doing this. I think I may actually have 2 too many constraints. I give it another go at it and see what happens. I noticed you're using size classes. I'm not using that. Should I be? I usually don't like using it because I'm presented with a big square and my background grid image doesn't fit on a square. It ends up looking like this . http://i.imgur.com/ZZU251K.png. Anyway I'll try it out. –  Mar 02 '15 at 19:55
  • Got everything working. I used Any x Any subclass and then set view to Aspect Fill and it all looks good. I now know what was confusing me before. When you mock up using subclasses the image is super stretched. Xcode does NOT use the @3x image for that preview. You need to actually build and run or use the preview window. That one little detail with subclass mode has been causing my confusion all along. Btw, is there a way to have ONLY the preview mode up? I can drag the window to the left to get more space but it doesn't go full screen. http://i.imgur.com/aWsX3DY.png –  Mar 02 '15 at 20:26
  • If you double click the storyboard or preview background it zooms out so that you can see everything. I like using the any height any width size class because the big square reminds me that it might not look exactly like what I see now one some particular device. I don't know how to have only the preview mode up, either. – Suragch Mar 03 '15 at 03:04