Get positioning (as CGrect) of Tab Bar Icon In swift 4 - animation

I'm trying to get the exact coordinates (as CGrect) of a specific icon in a tab bar controller in swift 4. I'm trying to create a minimizing "gene" effect into a specific icon at the bottom, but I cant seem to be able to reference the icon size/frame/coordinates in any way. This is needed for the animation end point.
Any insight on this?
Thanks

Related

iOS Swift Tab Bar Icon Insets Being Erased At Runtime

I have two ViewControllers inside a tab bar controller. In interface builder, I've applied image insets (5, 5, 5, 5) to the tab bar icons to get their sizes how I want them. Everything looks great when I initially run the simulator, but when I tab to the second ViewController, both tab bar icons automatically resize to the default (0, 0, 0, 0). When I tab back to return to the first ViewController, both icons remain trapped at default size with no insets.
Note: My icon images are .pdf files in XCassets folder (set as single vector Scale Factor). I've seen other threads which suggest "balancing" the insets (5 for top, -5 for bottom). But this would COMPRESS the image by 5 away from the top and STRETCH it 5 toward the bottom. I don't see how that's meant to balance the image size.
If anyone knows what code will set the insets at runtime, maybe I could use that instead of setting insets in interface builder? Thanks in advance.
Reading the documentation, UIBarItem (superclass of UITabBarItem) has the property imageInset, and you can access the tab bar items via self.tabBarController.tabBar.items.
Without testing it myself, I think you may have an issue with the insets getting reset when the shading changes (because of selection).
Thus, you may find that every time you change selection (and that can be detected via delegate I think), you'll need to reset the insets to the desired size.
Alternatively, you might find that just customizing the source image to the desired final appearance may be easier.

View Controller Gets Smaller When I Copy/Paste It (Xcode 7, Swift 2)

I would like to point out that I am aware of this question: How to copy or duplicate a ViewController in Interface Builder?
and that I followed its instructions.
When I do copy/paste said ViewController, the new "pasted" one is smaller than the original.
The two ViewControllers: One bigger and the other smaller
Another discrepancy between the two is that I can't seem to select the "pasted" ViewController's Navigation Bar to change its title.
What shows up in the Utilities area when I select the Pasted's nav bar instead of the "Title", "Prompt" and "Back Button" I get when I select the original's nav bar: Pasted's nav Bar.
Is there any way to get it to be the same size as it's counterpart and/or let me select it's Navigation Bar so that I can change its title?
Sorry if the question is a bit strange but bear with me please...
So there are two separate issues:
When you copy/pasted that VC, it no longer inherited from a segue its estimated size, so if you had for whatever reason a different size specified for the view it segued from, that is the size for the old VC, but the new one just gets the default size. If this is indeed the case, you can always change the size of the new VC by under Size Inspector, choosing Freeform and specifying it.
To get the navigation bar back, drag a Navigation Item from the Storyboard Object library onto your new VC and you can re-title it (and delete that button you added).

Use combined titlebar + toolbar while preserving title visibility

The System Preferences app feature a combined title bar and toolbar with vertically centered buttons and the title. I am trying to mimic this exactly in my app. I have been able to combine the title bar and toolbar using Interface Builder (on the NSWindow check Title Bar and Unified Title and Toolbar), but this does not center the content vertically. I discovered via this question you can simply set the window's titleVisibility to NSWindowTitleHidden which will vertically center the stoplight buttons. Unfortunately this of course hides the title. How can one vertically center content in the unified titlebar/toolbar and also show the window's title just like System Preferences - either in IB or programmatically?
I ended up setting titleVisibility to NSWindowTitleHidden and manually created an NSView that contains an NSTextField that mimics the standard title appearance, providing that to the window's addTitlebarAccessoryViewController method. Still would like to find a better solution to use the default title appearance, if possible.
I used WAYAppStoreWindow on GitHub to do this. I created a fork of the WAYWindow subproject to vertically centre the document title since this wasn't supported. This means any applied themes/appearances are honoured.

Xcode 5, ios screen issue

when I open my iOS project in Xcode 5, I see spaces bottom and top of the view controls (in 3.5 and 4 inch screens).
There are no problem in Xcode 4. Image view is not covering all view controls area.
I am setting image view size with manually but I have 200+ view control.
How can i quickly fix ?
Have you tried to hide status bar ?
It can cause the issue you are having
If the spaces are only appearing in Interface Builder, you can tell IB what you want to see during layout. Click below a scene on the bar where the controller, first responder, files owner etc. are located. Now your whole scene is selected. Then show the attribute insepctor (Cmd+Alt+4) and select what you want to see in your scene.
Attention - this has nothing to do with your code! Its just how the scene is presented in the editor (simulated metrics)!
If this was your problem, please mark question solved.
If not, please add some more details.
Thanks.

Buttons and input field into "top" bar

Safari on iPad has this bar at the top (it isn't called "toolbar" on iOS, right?), with some icons and input are for searching.
How to put such buttons and input field into Navigation Bar? Is it even a Navigation Bar? From what I read a Navigation Bar has one button on the left, another one on the right and one Label in the middle. But how to create something like that "top" bar from Safari?
If I'm in XCode 4.0 and choose "View-based app", should I then set in the ViewController > Simulated Metrics > Top Bar > Navigation bar? And how to add buttons to it?
Edit
Sorry for the confusion - I don't know if the proper way is to add to a Navigation Bar. I'm just asking for a general overview how such "top "bar" is made. What kind of View do such items belong under?
You probably don't want to use a navigation bar. They are very limited in what controls you can put in them. Try using a UIToolbar instead.
I think you may be looking for the UISearchBar
UISearchBar Sample Code
In the interface builder you should be able to just drag and drop objects onto the navigation bar, as for the little icons, those are just buttons with no border and images. Those images are preloaded in the iOS SDK, so you won't have to make them, but if you want your own then you can make them yourself.

Resources