Search code examples
iosswiftuiimageviewfacebook-ios-sdk

FBProfilePictureView not filling the assigned space in the storyboard


Well pretty straight forward.

FBProfilePictureView uses (by my knowing) all the UIImageView methods. Knowing this i tried to use AscpectToFit (first in the storyboard second in the code when the first one didn't work.

the i tried this:

   self.fb_background.contentMode = UIViewContentMode.ScaleToFill

This works only in height. I also tried resizing the frame this resulted in my images halfway down my page(instead of the top left

what am i doing wrong?

The problem is that my pictures width is not correct! its


Solution

  • The problem is that FBProfilePictureView contains a UIImageView and does not expose it for you to modify it's properties.

    It downloads a square image if pictureCropping == FBProfilePictureCroppingSquare otherwise it downloads a small, medium or large image depending on the width of the frame. But there is no way to control how this image is scaled to fill the FBProfilePictureView.

    I created a replacement view which exposes the UIImageView through a read-only imageView property and therefore allows you to control its contentMode.