How do i place a button in the background? - ios

I have quite a few labels and buttons on my view controller and I have an image and I have set it to the back in the layers part on the left. How ever when I make it bigger it seems to go to the front and block the images. I have tried multiple codes from other people who have the same problem, but it still doesn't work. I am using Xcode 8, Swift, iOS.

In interface builder you can change the order of what is in front or behind by changing the order of the views as they appear in the Document Outline...
The higher up the list they appear, the further towards the back they are.

Related

Place image on top of all "layers" on iOS screen

What are the constraints/alternatives to place an image that stays on top of all iOS "layers" and windows. Think of it as a lock screen but that still allows you to interact with you phone, meaning browse, answer calls, etc. The image will be displayed in a transparent way (say 40%) and will be launched by an application.
Not really sure what you are asking for but if you are looking for a way to add some code once and it shows everywhere on each of your ViewController then there really is no way to do that.
What you can do is
Use UIToolBar
add buttons to that tool bar
Add that tool bar to each ViewController in storyboard (where you need them)
Create a global function / method that you can call in from any ViewController that has the button actions in it. That way you edit the code once in one place and use it every where.
If you don't like UIToolBar then
you can add your own UIImageView and add a transparent background to it
Add your buttons on the UIImageView. (You will have to add constraints)
then show that on every ViewController
If all this seems to much work then you can use existing controls HERE and see which one fits your needs.
This maybe a good one - FCVerticalMenu

UIPageControl select dot and go to that page

I have aUIViewController, which has inside a UIView in which I add a UIPageViewController with the UIViewController as the delegate. The thing is that the UIPageControl of the UIPageViewController is not working as I had expected regarding the dots selection.
I was expecting that if I selected the dot 4, it would take me to the dot 4, yet, It doesn't work like that. It always goes to the following page if I select the right half of the UIPageControl (inside the blue square of the image), and goes to the previous page if I select the left half of the UIPageControl (inside the red square of the image). So, If im in page 2 and select around the second dot, it goes to page 1 (instead of staying on page 2)
Moreover, If I click exactly inside one of the dots (any of the dots), the click is ignored, although im not sure how this works on device (since in the device is more difficult to click exactly inside one dot).
My questions:
1 - Is ignoring exactly inside the dots behavior normal (by exactly inside the dots, I mean not around them)?
2 - Is two halves selection of the UIPageController to move between pages behavior normal?
3 - How can I make it so that if I press the dot X, it takes me to page X (instead of the current two halves behavior)?
Note: I prefer swift
1 - Is ignoring exactly inside the dots behavior normal (by exactly inside the dots, I mean not around them)?
I've never encountered this. I would say its not normal. Something may be overriding it.
2 - Is two halves selection of the UIPageController to move between pages behavior normal?
Yes this is the default behavior for UIPageController.
3 - How can I make it so that if I press the dot X, it takes me to page X (instead of the current two halves behavior)?
I would recommend not doing this. The reason that it isn't this way by default is the touch space is too small (when using a finger not a mouse). So it makes sense to only go forward and back. You'd have to create a custom UIControl to be able to do this if you really need to for some reason.
I would suggest you to use external library for that, as this problem was more or less solved. It is quite complicated to do by subclassing native page control but you can probably find implementation somewhere.
This library does exactly what you want (jump to page) :
https://github.com/Spaceman-Labs/SMPageControl
In the documentation, look for section "Direct Page Selection"
Hope it helps!
Edit: Few more libraries to look into:
https://github.com/TanguyAladenise/TAPageControl
https://github.com/nicklockwood/FXPageControl (very extensive, probably too much)

iOS: Add an image to the Navigation bar

I'm currently working on an iOS app that is pretty much supposed look and work like an already existing android app.
As a part of that, I'd like to make the top navigation look the same, but since iOs devices do not provide a hardware or software integrated back button, I'd also like to keep the back button navigation that's common to iOs apps.
I've tried numerous attempts to achieve it, but I'll stick with the latest I'm working on since it looks the most promising. I've started to work on a custom UINavigationBar class that overrides the initWithCoder: and layoutSubviews: methods. The result is as follows:
As you can see, the back button now overlaps the application icon. What I'm looking for is a way to make the button and the text to scale into the space right of the application icon. I've tried to handle this in layoutSubviews: but the superclass logic appears to be rather complex, I was not able to reproduce it's functionality (in particular it seems to be working with some private variables I don't have access to).
I also tried manipulating self.frame before calling [super layoutSubviews] but apart from endless loops I was not able to achieve anything in that direction.
I'd be happy if anyone could point me into the right direction.
If I understand your problem correctly, I think you could do this by adding a custom titleView to the UINavigationItem, and have an image view (on the left side for the icon) and a label (for the title) as subviews. This would replace the default title.

Using UIToolbar above UITabbar - is it possible?

My question is similar to this one, but not exactly answered there.
What I want to do, is to convert an existing navigation-based app with different UIToolbars at the bottom of the individual UITableViews into an app that has a UITabbar interface. One of the tabs shall show the same hierachy of UITableView data as the existing app (which displays some kind of hierarchical data), whereas the others will be assigned something else (say: Settings, Help, ...) that is of no concern here. The idea is to allow the user to quickly switch to the "Help"-Screen from whatever stage of the navigation stack - and back.
For example, using 3 Tabs:
1. Database root (UIToolbar) - folder 1 (UIToolbar) - file 1.1
- file 1.2
- folder 2 (UIToolbar) - file 2.1
- file 2.2
2. Help (no UIToolbar)
3. Settings (no UIToolbar)
I have never seen such a design in any existing app, although the question cited above suggests that it might in fact be possible to keep the existing UIToolbars from the old app and simply place them above the tab bar.
Is this
technically possible (without problems e.g. with device rotation)?
allowed by Interface guidelines?
Although sample code would be appreciated, I mostly would like to find out whether it is worth trying to build an app like this - or whether such a design is a bad idea in the first place.
You can have a UITabBar anywhere, you just won't be using its controller. You will have to write your own controller and handle what happens during device rotation (or use iOS 6's auto layout features).
I tried it out, and now I can answer my own question:
It's possible, and there are no problems with device rotation, if you make sure that the views for every single tab can rotate.
Although it looks a bit unusual, I find it very usable. Of course, it costs some vertical space.
As for the implementation, I found it to be surprisingly simple:
All I had to do was to use Interface Builder to insert a UITabBarController in place of my original main UIViewController and move the latter to the first tab of the former. Then create some more tabs with UIViewControllers inside and rename their classes to those of my other existing UIViewControllers. Finally set the associated NIB-Files for all these controllers manually in the relevant interface builder inspector pane (because they are now no longer instantiated by my code) and change one single line of code to make the UITabBarController the root controller.
Result: the UIToolbar appears above the UITabbar for the first tab, but not for the others. Its position is fixed (when scrolling a list or similar), but it autorotates together with the tab bar and everything else.

Unusually cool looking tab bar setup within a rootviewcontroller of a UISplitView

The ABC (Australian Broadcasting Corporation) iView app for iPad, has great looking tab like setup within a rootViewController of a UISplitView.
The tabs named "Browse/Watch/Listen" are particularly interesting are they simulated or real tabs?
It's unlike any UITabBar I've seen around in iPad apps.
Does anyone know how something like that is possible?
The round rect button in custom mode will be transparent and any png image will maintain in transparencies.
3 or more buttons with transparent images would be the way to go. A different color for when they are selected and your all set. You could also make them look like they are overlapping with images that continue the button next to it.
With the iOS devices it is more about appearance and less about the underlying functionality.
This is a custom control, they made themselves from scratch.
Fortunately for you, you don't need to make it from scratch. :)
There's a lot of open source component that does just this, just like these ones.
Those tabs look and feel like 3 UIButtons. Notice how the UI highlight acts when touching the buttons, and the action is only triggered on touchUpInside.
The tab content is probably a UITableView which gets refreshed when switching tabs.

Resources