How to make viewcontroller as popup - ios

I have created ViewController which has 0-0-0-0 constrains from superview.
And I recently got a task make this ViewController like a popup as shown in picture.
As you can see this white background which is my ViewController has some margins from left-right-top-bottom and shows some part of other ViewController.
How do I create this view in a quick way?

If you have given constraints in storyboard and not by programmatically, Then at the time giving constraints if the set to margin checkbox is checked, then possibly you have this space, which default margin to the screen.. :)

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:

change in vertical space of top element in viewcontroller

I have a view controller in navigation stack ... whenever after loading the view controller a change happens in vertical space of top element.
I don't understand why it happens ..
I have set top 5 for the top element of the view controller to the superview
I couldn't fix the problem no matter what ... status bar , top bar ,bottom bar,size are inferred
Info.plist I have set viewcontrollerbasedstatusbarappearance as no and I am setting the status bar as light content in app delegate once..
The problem that menioned not happens with all the view controller only with some viewcontroller it happesn
Thanks for any help
I think that you gave constraint like that,
So, change it as per below,
I hope it will work.
First, click on viewController in storyboard.
So, you will see at a right side corner is like this.
After that, Untick Under Top bars checkbox like that,
I hope this will work.

How to place any view below any other view which is getting it's position from code

I've created 4 subviews of white color & a yellow one as you can see in reference image I've shared below.
And I've programmatically changed the position of Tabbar from bottom to top just below to navigation bar as you can see in below image (When it is running in the simulator).
Now since I've constraints for that yellow view in image as follow
It is appearing just below to navigation bar but I want it to be displayed just below the Tabbar.
Since Tabbar is getting its position programmatically & other views (including yellow view) are getting their positions from the storyboard.
And since storyboard UIelements are get settled before any other UIelement which are coming from the program or at least get their position from programmatically.
What could be the best way to achieve what I want.
Please refer my storyboard as well to get more understanding. (Refer Below image)
I also want to fit all 5 subviews in the space between tabbar & bottom of the screen. I want to calculate 1/5th of that space & assign this height to each subview. I'd later reduce few pixels to separate them.
Why not add the height of the tab bar to the yellow view's top position? That way, you'd set the constraint something like:
Fajar.top = top + 44
If the tab bar is always visible, then that should work. But of course, if the tab bar only appears at times, you'd probably have to change that constraint programmatically depending on the change ...

How to make a tableview fill all the available space?

This is my first swift application, so apologize if it's very basic. I was unable to find it...
In my view, I've a Navigation on top (Navigation Controller) and It's using a TabBar Controller. I'd like to make the TableView fill the whole empty space no matter the size of the device nor orientation.
I set the property Content Mode to many different options, including Aspect Fill, but all the options can't cause any effect.
Any clue about it ?
First make your tableview completely fill the screen and then set the constraints to be in 0 margin from all sides, like in the image
use constraints for display full table view on empty space.enter image description here
Click on pin icon from bottom side of Xcode.
Select all for four(up,down,left,right) constraints and set 0 value for all.
after then click on add constraints button and refresh frame(click on right side button of Pin button and select Update Frame).

Why there is a border around the UIView?

In my story board I have added a new custom view controller. It is 'connected' to the RootView Controller via a push segue.
This is the new custom UIViewController as seen in the storyboard
When I run my app in the simulator, I can see a border around the frame. (Of course it is visible because I set a background color to RootViewController)
I want to understand:
1) Why my custom view controller does not occupy the whole frame?
2) what is the orange color dotted line? Is it related to the question 1? What is the best practice (i.e. is the border a new behaviour and is not indicative of bad design etc)?
The orange dotted line shows that the view will change when the constraints are resolved, and shows where the view will end up.
If the view is correct in Interface Builder, just go to the Resolve Auto Layout Issues popup menu and select Update Constraints. That will update the constraint values to match the layout in Interface Builder.
If you select Update Frames instead, that will make the view match the constraints (causing the view to shrink to the orange dotted line in this case).

Resources