Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to use autolayout in XCode to position these two images like they are in the screenshot, but when I run the simulator, they're in the wrong position. Here is basically what I want to do:
scale the images up if the screen size goes up (and vice-versa)
have the dog picture just above the middle of the screen
have the loading picture a certain distance below the dog (i.e: loading.y = dog.y + screenheight/4)
I have not gotten the hang of autolayout yet so any direction to what constraints I should use would be appreciated.
Image of View Controller
You would really benefit from just spending time reading through auto-layout tutorials / articles / discussions / documentation / etc.
Here is an example of what you are describing.
Using these two images:
You can lay out your image views in Storyboard like this:
The dog imageView has:
Centered horizontally
Bottom constrained 90% to the CenterY position (just above the middle)
Width is 50% of the safe-area width
Height determined by Aspect Ratio of 236:175 (the original size of the image)
The loading imageView has:
Centered horizontally
CenterY constrained 1.75% to the CenterY position (effectively screenHeight / 4)
Width is 75% of the safe-area width
Height determined by Aspect Ratio of 368:76 (the original size of the image)
and here is how it looks on 3 different device sizes:
The best way to learn this is to just work on it.
Related
I'm trying to constraint one dog image so that it is centered vertically in the container, which I can do. What I can't seem to get it is having it just above the halfway horizontal point. So I want it to be a certain fraction down the screen (say a third) on any device. I also want the size of the image to be relative to the screen size.
I want the image to be about what it is in the image but maintain its proportions relative to the device of the user.
I've tried tons of things and none of them work. Any help is appreciated.
Here's the Image
Create an UIView and set the image to fill the UIView. After that make the UIView top constrain equal to the centerY anchor which makes the UIView below center horizantal. By using layout anchors for width and height ( not fixed hard coded numbers) you will make it's size relative to device size so doesn't matter using any device type. Post a graphical design if you need more specific answer.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm adding an image but it won't go fullscreen with the iPhone XR, it has white space around it
I tried zooming it in and out for refreshing it, but still won't go fullscreen
I expect the image to go fullscreen
It sounds like you've aligned your image to the Safe Area guide rather than the view edge.
Safe Area guides are inset a bit on iPhone X/XR devices to allow space for the home indicator or the sensor housing (notch). If you want your view to fill the superview, make sure your layout constraints are attached to the superview edge rather than the Safe Area edge.
To fix this, edit your existing constraint from the storyboard, changing the item from Safe Area to Superview:
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am fresher in Swift language. If I take the size of inferred instead of any other, it will effect in constraints? In which size I should do designing is there any proper method for constraints.
Inferred size means that the Storyboard infers the scene size according to its super-scene size (the parent's size).
If you have a scene that is the size of an iPad and then you add a new scene to your storyboard and create a segue to it, it will automatically resize to the same size as the iPad scene (where the segue originates from).
Freeform ignores the above rule and you're able to size the scene as you like, in the utility pane on the right.
This setting does not affect constraints, and how the view is displayed on actual devices. For that, you need to use AutoLayout and constraints.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Trying to figure out how to incorporate this effect into my app.
It is essentially the adjustment of the colors in the speech bubbles when the user scrolls, as seen in the messages app in iOS 7.
The bubbles close to the top of the screen are light blue, the bubbles towards the bottom are darker.
Create a gradient on your views. Set the start and end color's intensity according to the view's position in the scroll view's superview (using convertRect:toView:). As your scrollview scrolls, update the visible bubbles' background colors according to their current position. An optimization is to only update the views which are visible. Using a table or collection view can help you with that. It's a simple yet effective effect.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an array of images, these images can be taken from camera or photo library, so it can be on different sizes.
The images are displayed as thumbnails like on photo library, and my goal is to show one image on screen with a screen related size once it is tapped, then i can move to the next image with a gesture, also as the photo library.
My main problem is i don't know the size of an image view to fit the images on screen, i tried to scale them, but as i can have several sizes of images i can't find a pattern to scale (images of different sizes should be scaled differentially).
So, how can scale these images to fit on screen proportionally to it's size(again, like photo library)?
On UIImageView you can setup a scaling mode that should help fit the images onto the screen as nicely as possible. Essentially you want to "fit" the image onto the screen by either padding the small sides with empty space, or clipping the edges of the largest sides.
Keep imageView.frame uniform for all images and play with both of these options to find out what works best for your needs:
/* no clipping - empty space on sides */
imageView.contentMode = UIViewContentModeScaleAspectFit;
/* clipping - no empty space */
imageView.contentMode = UIViewContentModeScaleAspectFill;
An answer (scroll down) here illustrates the difference with a nice diagram:
How to scale a UIImageView proportionally?
did you already check the Collection View Controller? You use that kind of container type for your application.
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/Introduction/Introduction.html
Another way would be to add implement an own logic... You create several e.g UIImageView's and than implement an logic to detect the smallest one. Based on the smallest "frame" you resize the other Views till they match the size of the smallest UIImageView based on his height...
But I think its much more comfortable to use the collection container :D
In addition here is an tutorial how to handle it if you dont want to read the full documentation from apple but I recommend to read it anyway!
http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12
this tutorial was created by Brandon Trebitowski
thank you
best regards