How to reduce the height of ViewController - ios

On a button click, i am opening a viewcontroller as a popup. But it should not occupy the whole screen. It should be 70% of the screen.
I tried to reduce the height of view controller with properties and CRect size. But it is not reducing the height.
how to reduce height of view controller?

its an easy fix.
add a UIView inside you ViewController and set the constraints as desired.
set the background color of the ViewController to be transparent.
click here to select the parent view in the ViewController.
then, click on the color next to background and click custom.
finally, drag the opacity all the way down to 0 as shown in the image.

Related

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 ...

Recreate UITabBar to UIToolbar on select from Photos app

I need to do exactly what the photos app is doing when you press the select button. Basically just hides the UITabBar and presents a UIToolbar. For some reason this seems to be incredibly difficult if you don't want to implement a complete hack. I found a hack if you shrink the height of the UITabBar and change it's alpha to 0 but when you set it's height back to the default the image and text is condensed.
Turns out that I ended up just needing to call [self.tabBarController.tabBar setHidden:YES] to hide the tabBar and instead of using my existing UINavigationController's toolbar I create my own instance of a UIToolbar and add it as a subview of my view controller. Then using autolayout I pinned it to the leading, trailing, and bottom edge of the view. This handles rotation and other issues.

Using Autolayout, unable to move the navigation bar down 20px

I have a UITabBarController which has four tabs. One of those tabs opens a my results screen (a UITableViewController).
On showing this screen, I want to move the UINavigationBar down 20px (to make room for a custom UIStatusBar which I show on all screens).
On all my other screens, I add some code to the viewWillAppear method to change the self.navigationController.navigationBar.frame.origin.y to 20.
but these are all "non-root" screens (i.e. a pushed view with a back button).
However on THIS screen the UINavigationBar must be initially visible, even though it is the root view. I use the same code, but it doesn't move the view down.
I'm assuming autolayout is moving it back into position, so I tried adding this code into viewWillLayoutSubviews and viewDidLayoutSubviews. But when I do this the navigationbar doesn't move down until the first time the tableview is scrolled.
What do I need to do to force the navigationBar to move down (and stay down) before the screen appears?
Are you using storyboards? Set the Y in storyboards to 20, Make your viewcontroller implement UINavigation bar, then add this code:
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar{
return UIBarPositionTopAttached;
}
This will tell the app that the navigation bar is to be attached, it will remain at 20px but extend the background all the way up.. So essentially it'll look like it's at y = 20.

How do I make a button slide to reveal like the UITableView delete confirmation button?

I would like to re-create the animation of the delete confirmation button that Apple uses in the default implementation of UITableView. I want to create this button and animation in my own custom view area, but haven't been successful in finding a proper view transition or animation. Here is a picture of the reveal animation half way through:
And here is a picture of the animation after it has finished:
These are screenshots from a YouTube video that shows how the button animation is supposed to look.
Thanks!
Basically,
1) Put a button inside a view of the same size as the button, with the autoresizing masks of the button set to force it to not shrink when the view changes size, and have a left flexible margin.
2) Animate the view's frame to change from 0 width to full width while moving from x origin to (x - view width) origin.
As the view grows the button will be revealed. The view should have clipToBounds set to yes.

Custom UITabBarController moved to top leaving white area

I have a custom UITabBarController and using setFrame in the viewDidLoad I move the tabBar to the top of the screen. This works fine.
In Interface Builder I have pushed down the elements (buttons, labels, etc) in the XIB file of the so that there is room for the tabBar at the top. I have made sure to set the Bottom Bar to none (in the simulated metrics of the inspector) and made sure that the UIView is 480 in height.
When I test this however the tabBar is at the top as expected, but the view is clipped off where the tab bar would normally be. Even the background UIImage does not show through. It is just white. How can I increase the frame size of the viewController?
I tried changing adding a setFrame command to [self view] in the viewDidLoad of the subview, but that did not do the trick.
Thanks
UITabBarController automatically sets the frame for active view controllers.
You can try to modify the view's frame afterwards or try setting clipSubviews = NO for all views.
Maybe you want to try to execute the following in viewDidAppear: or some other place (try!). This will hopefully change back the frame of the view after the tab bar controller modified it.
dispatch_async(dispatch_get_main_queue(), ^(void){
[self.view setFrame:CGRectMake(0,0,320,480);
});

Resources