Here is my status I created stack-view with two sub views --> vertical and horizontal stack-view
the horizontal view contains 3 button
check image below
my issue when I set background to button its stretched as appear in image
my tries to fix this issue ,
1- set view mode to aspect-fit
2- increase spacing between button
3- set fixed width and height to one of buttons as all obey
but unfortunately all my tries doesn't work , any one could guide me to fix my issue thanks
Have you try to use SetImage Instead of BackgroundImagethat will fix the issue else use the proper image with proper size that you want to implement based on your requrement. see the following difference between setImage and SetBackgroundImage
Here you need to change your image size with your stack view's button image that will be fix your issue and for using stack view following is a good link: https://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views
Related
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.
I am creating a launch screen for my app, I have a picture in an Imageview that I want as a backdrop for a Label containing the title of the app.
Screenshot of the image in the background with Label in front of it
I was able to shift the Label to the front of the launchscreen.storyboard, so that it is on top of the Imageview, by changing their position in the viewcontroller index.like so
When I load the sim for the app, the image doesn't appear, so it ends up looking like this:
screenshot of launchscreen.storyboard
I haven't the foggiest ideas as to how to resolve this issue.
(Sidenote, I'm aware that nothing on the launchscreen.storyboard is aligned properly; I've removed all the constraints and I've been moving the moving things around in an effort to figure things out)
Is there something I need to drop into the Viewcontroller to make this happen?
I'm kind of at a loss..
Set the constraints to the image view to 0 for top-left-bottom-right. For the label, set the constraints to the top, center it to the page, and then set the size you want it to be. Sometimes when you change auto layout a lot within Xcode it gets buggy. You may want to delete all constraints and start fresh.
I am trying to modify a frame work and have encountered the following problem.
I have replaced one of the button image in the framework's xib file with my own one. The image itself is approximately 20Wx20H but I have set the button size to be 40Wx40H so that the clickable area is larger than the actual image.
When the VC is displayed, I see the image to be normal 20x20 aspect ratio. However, when I clicked on the button, it stretches to 40x20 and goes back to default upon release. I was wondering if there is a UIButton parameter that I can disable which was enabled by the framework somewhere? I have done a search on the buttons in the code and could not find anything relating to stretching the button. So I am guessing somewhere in IB there is my solution?
Below are the images for the button when touch down or not touched down.
Have you tried the following?
button.imageView.contentMode = UIViewContentModeScaleAspectFit;
Also are you using autolayout? If yes, what are the constraints?
I have an image that is using Auto-Layout constraints. The image is a blackboard. I want to fix a view to fill the blackboard, so I can put some labels in there, as if it had some written things in the blackboard. I tried to use constraints in this view, but never fills the blackboard. How can I do this?. I uploaded an image to be more specific. Thanks!
P.S.: I colored the View.
Hey I'm learning developing in XCode with Storyboard and I have an UIButton with custom image. Before I developed without Autolayout but then I read about it and decided to try it. My problem is that the button has a custom image and it shouldn't display a title, only the image. When I don't use Autolayout everything works just fine (only image is displayed). But when I turn Autolayout on, it resizes my picture and pushes it to left and shows button title next to the image. How can I display only the image using Autolayout? Has this something to do with intrinsic content size??
Try my answer:
button.titleLabel.hidden=YES;
Try to:
button.autoresizesSubviews=NO;
Or:
button.titleLabel=UIViewAutoresizingNone;
Or:
button.imageView.autoresizingMask=UIViewAutoresizingNone;