How to use ImageSlideshow and a label - ios

I'm using this library as slideshow:
ImageSlideshow
now,I want to add label over it but that show behind of image :
I cannot change position label title and image slider.

You can call label to front by
try this
self.view.bringSubview(toFront: yourlabel)
or use
yourimageslider.bringSubview(toFront: yourlabel)
or use
yourscrollviewName.bringSubview(toFront: yourlabel)
You can send image view to the back by
or could use
self.yourscrollviewName.sendSubview(toBack: yourImagesliderName)

You can use
self.view.bringSubview(toFront:subViewObj)
subViewObj might be your label, But subViewObj should be added some where in root view. Here the root view is self.view.

Related

How can I bring a view in front of another view, in Swift?

Below are how my views are organized in IB, top->bottom when the app is started.
The user can do something to make "Category Table View Header" temporarily expand over "Name View" - however once doing so, the .TouchDown action assigned to "Category Table View Header" no longer works wherever it overlaps with "Name View" (i.e., the user can tap the header anywhere it doesn't overlap with name view and it still works).
I know that may be confusing, so I drew out some boxes. On the left is the original, right is after user action - problem is on the right the action on the red box only works if the user taps the bottom half, not the top half.
My guess is its because the header is lower in the view hierarchy than the name view, but it would be hard for me to change that without messing around with a bunch of constraints.
I also tried setting nameView.hidden = true, but that doesn't work.
If you want to bring a subview to the front, you can use:
SWIFT 4 + UPDATE
self.view.bringSubviewToFront(yourView)
SWIFT 3 UPDATE
self.view.bringSubview(toFront: yourView)
Send view to back:-
SWIFT 4+ UPDATE
self.view.sendSubviewToBack(yourView)
SWIFT 3 UPDATE
self.view.sendSubview(toBack: yourView)
SWIFT 4+ UPDATE - INSERT VIEW ON SPECIFIC LOCATION IN THE STACK
parentView.insertSubview(yourView, belowSubview: requiredViewOnStack)
parentView.insertSubview(yourView, aboveSubview: requiredViewOnStack)
Swift 5.1+
UIKit draws views back to front, which means that views higher up the stack are drawn on top of those lower down. If you want to bring a subview to the front, there's a method just for you: bringSubviewToFront(). Here's an example:
parentView.bringSubviewToFront(childView)
This method can also be used to bring any subview to the front, even if you're not sure where it is:
childView.superview?.bringSubviewToFront(childView)
In Swift 5
To bring a subview to front
self.view.bringSubviewToFront(yourView)
To send a subview to back
self.view.sendSubviewToBack(yourView)
You can take a control over the order of subviews using methods: bringSubviewToFront and sendSubviewToBack from the superview.
You can access all the subviews contained by superview using self.view.subview array.
The method has been updated since swift 3
What has worked for me and hopefully for you is using :
YourView.bringSubview(toFront: yourelementA)
YourView.bringSubview(toFront: yourelementB)
Alternatively you could use the following to send the object that is in the front:
YourView.sendSubview(toBack: yourelementC)
I hope this helps
Swift 5.4
views in UIKit are drawn from the back towards the front (like adding icing onto a cake). This means that the new views will be placed on top/over the previously placed views. (e.g. Icing is the new view and the base of the cake being the old view.
You can use the following to manipulate the views Z-position using,
Forward
parent.bringSubviewToFront(child)
Backward
parent.sendSubviewToBack(child)
bringSubViewToFront did not work in my case, Take a look
As I wanted this notification count comes before image, bringSubViewToFront did not work, So I just drag this label below to stack view of my imgae and bottom label, it worked for me.
I hope this will work for all

How to assign a higher level on a uiview in order to make it override another view?

I created a uiview and added a sub-uiview on it. Then I allow user to drag the sub-view around the screen freely. But I have problem when moving the sub-view on top of the screen. Please see below picture. The sub view override the top uiview on the screen. What I want is to let the top uiview to override the sub-view. How can I change the level of a uiview in this case?
when I use self.titleView.bringSubviewToFront(sv)
I see another problem as shown in below image. The status bar is not at the top of the image view.
You can use bringSubviewToFronton parent view to bring sub view to front as follow:
objective-C:
[parentView bringSubviewToFront:childView];
swift:
parentView.bringSubviewToFront(childView)
Edit:
use below method to manage views:
bringSubviewToFront(_:)
sendSubviewToBack(_:)
removeFromSuperview()
insertSubview(_:atIndex:)
insertSubview(_:aboveSubview:)
insertSubview(_:belowSubview:)
exchangeSubviewAtIndex(_:withSubviewAtIndex:)
like,
self.view.sendSubviewToBack(myView)
For more detail check: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/#//apple_ref/doc/uid/TP40006816-CH3-SW46
Hope this helps :)
parentView.bringSubviewToFront(view)
UPDATE
Pay attention: you must considered that parentView is the parent of your view. To explain better this concept if you have a line like this:
self.container.addSubview(view)
so self.container is the view parent's, dont confuse it with the view below your view...it may not be the same.
If your draggable view is a subview of the image view try to set masksToBounds to true:
imageView.layer.masksToBounds = True
But the reason of your issue is probably because you set zPosition of draggableView.layer to some positive number. Usually it is better to use methods such as insertSubview(_:aboveSubview:) and bringSubview(toFront:) to manage subview's order.

Bring UIButton to front layer

I know there is a way of bringing a subview to the front of the hierarchy. However is there a way of bringing a button that i have placed on a story and calling a function that will make that button the top layer so its not hidden by any other elements that are added that aren't in the story board.
Thanks,
I am late for this question, but not too late to answer it by Swift 3
Swift 3
view.bringSubview(toFront: theButton)
A UIButton is a UIView, so you can call -bringSubviewToFront: on your button instance.
uiview's are displayed in the order they are stacked. One can change this to say were to insert the new uiview, which in your case is a uibutton.
One way of doing that is by creating a IBOUtlet of the uibutton and adding that button instance as a subview/newview above an existing uiview.
CODE:
[self.view insertSubview:<new Uiview> aboveSubview:<existing uiview>];
Also if you are not able to figure out the order of the uiview , then you can check that in xcode
When running the project in debug mode under debug window there is a button(highlighted in below image) Debug View Hierarchy, you need to click that. (highlighted in below image)
After that you will able to see all the views rendering on the screen at current instance, using this feature you will be able to understand were is your new uiview in the uiview stack order(shown below).
Swift
The following works great if the view you are working with is being hidden views that are in the same view.
superview?.bringSubviewToFront(self)
Swift 5
In my case I had to insert my view behind some buttons. By insert it at the zero position it was placed behind the buttons.
self.view.insertSubview(self.mapView!, at: 0)
i have the same problem with you and a friend of mine helped me
i can bring my button to another subview using this function on your view controller where you declare your button.
override func viewDidLoad() {
super.viewDidLoad()
UIApplication.shared.keyWindow?.addSubview(chatButton)
}
button.superview?.bringSubviewToFront(button)

Add icon to SBSearchTableViewCell

I am trying to add an icon to a SBSearchTableViewCell.
I was adding a subview on top of the cell but that still left a border, and the text was underneath the icon.
http://i.imgur.com/tGqWaEa.png
I tried hooking into -[SBSearchModel _imageForDomain:andDisplayID:] but the domain is 0 and the displayID is (null).
Code: http://pastebin.ca/2460380
Resources:
http://theiostream.tumblr.com/post/54339870761/hacking-the-ios-spotlight-v2
https://github.com/theiostream/SearchLoader
Did you try to set image using -(void)setTitleImage:(id)image animated:(BOOL)animated; method (I'm not sure what it does, but that is the only method to set image in the cell you are using...)? And, How about just creating your own labels, and place them on the right places? That should not be that hard, I think. Good Luck!
EDIT
Sorry it seems like the method I mentioned is available only on iOS 7 and higher. I suggest you to use you own UILabels and UIImageView with imitation to the original.
ANOTHER EDIT
It looks like the SBSearchTableViewCell is the subclass of the UITableViewCell, so why don't you use the it's imageView property to set the image (or, icon) to the cell?
You can move the border over by setting cell.sectionHeaderWidth. Then you can add a subview like you already have done.

How can i add the customized slider with previous and next buttons to the view in iphone?

In my app i need to display the slider,to scroll the view by view.(page by page).how can i?
I need to disply the slider as above image
You would have to subclass it and initialize it with that image or whatever image you want it to look like.

Resources