1

I am writing some code for my home screen for a new app I am working on. On the home screen I have a GIF image running in the background with a FB(Facebook) login on the front screen.

My issue is that I am trying to run auto-layout programmatically and am trying to center as well as stretch my GIF file to make it through out the entire screen. Here is the current code I have so far in regards to the sizing:

var webViewBG = UIWebView(frame: CGRectMake(0, 0, self.view.bounds.size.width, 1250))

webViewBG.loadData(gif, MIMEType: "image/gif", textEncodingName: nil, baseURL: nil)

webViewBG.userInteractionEnabled = false;

self.view.addSubview(webViewBG)

I am looking to get this to center on iPhone 4s - 6+, however I am unsure if this is related to the GIF size or if I am using the wrong code by implementing CGRectMake in the code.

fpg1503
  • 7,492
  • 6
  • 29
  • 49
RILEY
  • 65
  • 1
  • 8
  • Why is 1250 hardcoded? Do you want to keep the aspect ratio cropping the image or filling the screen without cropping the image? What should happen when the user rotates the device? – fpg1503 Feb 01 '15 at 02:27
  • I just had the 1250 hardcoded in there to try and my my video full screen without the white spacing on the iPhone 6s. I am not to worried about the aspect ratio of the image as long as I can center the GIF. This app is currently in portrait only mode so the image will be vertical. Also looking at my code now the CGRect function is for a rectangle as opposed to vertical correct? – RILEY Feb 01 '15 at 02:37
  • Close this, decided to go a different route – RILEY Feb 01 '15 at 06:12
  • I don't see any "trying" to run auto layout. Have you tried to add any NSLayoutConstraints? – rdelmar Feb 01 '15 at 06:30

0 Answers0