2

So, I'm learning iOS Swift. I'm going by some tutorials, and I'm stucked at image positioning.

I'm trying to figure out how uploaded picture is rescaled and positioned.Since I cannot post the screenshot, image that should be shown in my simulator as whole, I can only see like 25% of the picture. Should I change something in Attributes or in Size Inspector?

What I did so far (clearly wrong), was setting Intrinsic Size field -> select Placeholder, w/h = 320.

Then, I pinned and selected Aspect Ratio.

Any help, please? Thanks.

Satchie
  • 21
  • 1
  • 3
  • You can set the frame in code, image.frame = CGRectMake(10,10,10,10), you also can control drag to set width and height auto layout constraints. Cheers! – Rob Norback Sep 23 '15 at 17:53

1 Answers1

2

If you're asking how to make sure an image fills a UIImageView:

myImageView.contentMode = UIViewContentMode.ScaleAspectFill

You may also need to set constraints if you placed your image view in interface builder. enter image description here

It's not entirely clear from your question how you want it positioned, but hopefully these get you on the right path.

Chris Slowik
  • 2,859
  • 1
  • 14
  • 27
  • Here is the screenshot: http://postimg.org/image/g3577ikjb/ As you can see from it, my photo should "shrink" to fit the screen... I cannot explain it better. Thanks. – Satchie Sep 23 '15 at 18:04
  • Looks to me like you need to set up some constraints in interface builder. Based on your screenshot I'd probably add a top constraint and both side margins (which will keep it centered and full width - also set aspect ratio so it scales proportionally. Something like: http://prntscr.com/8jo1u5 – Chris Slowik Sep 23 '15 at 18:11
  • Thanks... I'm trying, with no success. But will succeed, I hope. – Satchie Sep 23 '15 at 18:28