FBProfilePictureView not filling the assigned space in the storyboard - ios

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

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.

Related

Increasing size of image in UIButton

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.

How to avoid distort and stretch image in Custom UIButton while using vector image set?

Below is my storyboard, I had quite a lot of constrains to make those four buttons fit into the screen nicely. However, after I put the images into the buttons and check the storyboard preview, all images are distorted. I try to adjust (had tried all of the options) the view mode at attribute inspector panel but seems no effect at all.
One more thing, I am using PDF as vector type image set, not regular .png file I am wonder if that matters? Should I change the way vector image displayed inside UIButton programaticly?
The verctor image size was 500px*500px. I resize the image into 50px*50px after #orkenstein 's reminader, xcode may not be able to handle oversized vector image that well. The image appear inside button as it is exactly 50px*50px and lost its ability to scale. Also as he sugested I should but the vector image inside an UIImageView and after my test, it works perfectly fine in an UIImageView.
Setting the contentMode on the button itself doesn't work for me, but setting it on the button's imageView does. From this Stackoverflow answer:
button.imageView?.contentMode = .scaleAspectFit

Adjust UIView inside UIScrollView MultiOrientation

In my app i receive a image dynamically.
After process the image i need to add some views on top of that image (after the user can drag this views).
To accomplish that, i put the image on UIImageView and add the views on that UIImageView.
According on its dimension i need to adjust the UImageview to fit the screen, but maintain the original scale.. The user can also make zoom.
The main problem appears when the user rotate the device. I need to adjust the UIImageView and it´s subviews correctly to maintain their relationship with the image.
For example in portrait:
And Lanscape:
My doubts:
Correctly adjust the UIImageview´s size, maintainig it´s original scale.
Adjust the subviews to maintain their relation position to the UIImageView.
Thanks in advance

AutoLayout button with image is resized to actual image size

So, using Objective C, I have a button to post to Twitter. I saved the image and placed it in my supporting files. I have the button looking like this: http://i.imgur.com/z8Pswxq.png in the storyboard.
But when I go to simulate the app with iOS simulator for it ends up looking like this: http://i.imgur.com/KW3oQYg.png
It seems to revert back to the size of the actual image no matter what. I can't seem to see a way to make it the size of the button. Unless is there a way to programmatically do it? Probably missing like, a checkbox somewhere.
I'm sorry about posting the links instead of using images: have like, 1 reputation.
Presumably you don't have any explicit constraints that are dictating the size of your button. The size of your button is being dictated by the button's intrinsic content size. In this case, that content size is the image size.
Either resize your image (e.g., programmatically or in your favorites graphics program), or install explicit constraints on the button that dictate the button's size. The constraints could be installed in IB by control-dragging with zero code.

Zooming an UIView without losing detail

Let's say I have a complex UIView, which is initially on the screen with quite small frame, let's say 80x80.
One of its subviews is an UIImageView displaying an image whose actual resolution is 1024x1024.
When the user tap the UIView i want the view to zoom in almost full screen so that the user can better see the image.
I know already how to scale a UIView to zoom in, my question is the following.
What's the best way to zoom in this view without pixellating the image?
I thought of these options:
I can actually set the frame of the UIView to the full screen size, and normally scale it down, so I'm sure that when it's zoomed in, it will be perfectly detailed. This solution anyway have a strong performance issue, cause moving around many of these scaled down views, will be quite an hit on the CPU/GPU.
I can do it just as I described, so small frame and scale > 1 to zoom in, but in this case will the image be displayed without pixellating?
I can actually set the frame to redisplay the view at the big/small size. In this case the detail will be good, but I have a performance hit here too, because my UIView have around 15 subviews that need complex calculation to relayout, so it's not so "fast" to set the frame.
Which is the best solution? Or do anybody have any other better solution?
Why dont you just have thumbnail representations that are 80x80, and when the user taps on any thumbnail, you transition from your current view containing all the thumbnails to a new view with the +transitionFromView:toView:duration:options:completion: method and simply display a UIImageView with the full resolution image loaded into that new view :)

Resources