How to pin image to screen in Swift? - ios

How can I pin an image to the screen like the profile picture in Snapchat on the top left corner? What should I should learn?

I am guessing that they have used ContainerViews. ContainerView is a resizeable View which can itself contain a View Controller. So you can put a ContainerView inside a View Controller and pin the UIImageView to the View Controller (using Constraints) on top of the Container View.
Make sure the UIImageView is in front of the ContainerView in the view hierarchy so it is visible.
Watch this to get some idea about ContainerViews.

Related

Remove top space UIScrollview in UIVIewController

I am implementing a UIViewController, it has tabbar, i have added scroll view but on iPhone X onwards, it is showing some extra top area.
How to remove that, so that image becomes full screen from top?
I'm not sure how your view hierarchy is set up, but assuming you have an UIImageView you should make sure that the top constraint is set to superview's top not to the safe area.
If you are working with storyboards you should go from this:
To this:
If your constraints are set correctly it could also be from having automaticallyAdjustScrollViewInsets set to true on your view controller.
You can change that from storyboard as shown bellow:

Rounded button above the UISCROLLVIEW

I have been working in a project which has a uiscroll view where the uiscroll view size is set programatically with height 225 and width is self. I have created two uiimageView where it displays two images and I have animated it by moving using a page view controller. Finally the image moves atomically like a slide show with page view controller. I have removed the navigation controller do I need to keep a back button for navigation when I place a unbutton above uiscrollview it was stating like scrollview ambitious scrolling content. I need to place a rounded back button above scroll view. I have attached the image of my storyboard. When I tried to place a button it is not visible in stimulator header scroll view is the UISCROLLVIEW where the animated image is placed

How to show UIButtons present on the view controller

I had a UIViewController on whose view I had started an AVCaptureSession and added two UIButtons to capture photos and close the camera,
I was facing the issue that the AVCaptureSession was also getting rotated when I was rotating the device,
To solve the problem I followed the second answer on this link,
<https://stackoverflow.com/questions/7353789/ios-disable-autorotation-for-a-subview>
But after adding on the window if I am making the view on the window of the full width and height as the self.view I am not being able to see the buttons
Any suggestions how I can bring the buttons visible while adding the window view as full width and height as the view of my view controller.
You will probably have to create a subView of the "full width and height" view that you have created, and put the buttons over there (instead of in self.view).
Edit:
You might also try calling bringSubViewToFront on both buttons.

Hide Bottom Bar When Pushed through Autolayout

I have a UITabBarController with one UINavigationController holding a UIViewController as root view controller.
when tapping one of the button in the UIViewController, I push a regular chat window UIViewController (with TableView + Input View) end hiding the bottom tab bar. (using the "Hide bottom bar when pushed" flag)
In storyboard I added a regular UIView subclass to VC that look like a bottom bar, and I use Auto Layout to pin it to the bottom of the VC view.
The problem
when I push VC it takes a second for this view to pin to the bottom, it looks like auto layout pin it to the bottom as if the tab bar is not hidden and after a sec it recognise that the tab bar is hidden and moves it to the real bottom of the view.
For clear info check this screen shot
Now I will let you the know the constraints of the table view..
Now I am showing the constraints of the InputView
I am also adding my View hierarchy...
I had a similar issue in my project. I solved it by selecting the view I wanted anchored to the bottom (in your case, the input view), held Command, and selected its superview (both views should be highlighted now).
Then I selected the align button at the bottom of IB:
And added a Bottom Edges constraint.
What I had done initially is used the pin menu to pin the view to its superview, but it appears that will pin it to the bottom layout by default, which causes that weird movement during the transition.
EDIT:
After seeing the latest screenshot, the problem could lie in one of the superviews. I'm assuming that chatWindow is a UIView, and your Scroll View is horizontal only. Here's what your should check:
chatWindow is pinned to the scrollView's bottom similar to what I've outlined above.
scrollView is pinned to its superview as I've outlined above.
Moving the inputView outside of the scrollView to the root superview. Then one by one move it down the hierarchy towards its current location.

How do I bring the subview over the scroll view on iOS?

In iOS development, I want to add a subview in a viewbased application. I am having scrollview above that am having views containing labels and I used Interface Builder to design these views.
How do I bring the subview over the scroll view?
The way I do do this in IB is set the View Mode in the document window to Outline View (2nd button). Then I drag the view from the library on top of the scroll view and it will be inserted as a subview of the scrollview.
If you get a disclosure triangle next to your scrollview it will have had the new view inserted as a subview.
If you mean in the xib, drag the scroll view in first then drag your other subviews onto the scroll view.
If you mean programmatically, this should work:
[scrollView addSubview: mySubview];

Resources