UIButton over an UIImageView via storyboard - ios

I want to create my view as below:
For which i have figured out i need an UIImageView to display the default profile pic and a UIButton with an image of camera over the UIImageView. I added an UIButton over the UIImageView, but when i run my code it is not visible. I tried changing the background color and added some text on the UIButton but the UIButton is not displayed. I have already gone through similar questions but most of them were solved by adding the code for UIButton and UIImageView and not via storyboard. Can someone point out where i am going wrong.
Also any other suggestions to make similar view are appreciated. The one i can think of is to use and UIImageView instead of UIButton and enable it's user interaction. But that isn't much different than using UIButton.
Thank you.

Try below line of code :
[btn.superView bringSubViewToFront :btn];
Write above line of code at the end of - (void)viewWillAppear:(BOOL)animated mathod.

Try to drag the button from the document outline as it comes after the ImageView. Check the images given.

Check in document outline in storyboard and check view's stack.button should be above imageView(below in document outline). if not then change position by simple drag and drop. Hope this will help :)

Related

UIbutton click issue - Swift

I'm trying to add login button overlap on subview, the touch event for uibutton does not work on lower-half.
Can anyone provide me an idea to achieve design like this, with touch event work on all corner ?
You view set up should look something like:
As Inderjeet mentioned in his comment, "You have to keep button outside the UIView otherwise it is not tap-able. Maintain the position of button according to UIView by using constraints."
Now to answer why, set clip to bounds property of your view to true. You will see, on run time, portion which is not tap-able, is also not visible.

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)

Round Rect UIBarButton in iOS 7

I Am trying to create a UIBarButton as a flat Round Rect. sort of a mix between iOS 7 and 6.
Heres an example from the Facebook app
I want a Button that looks like the "send" button.
Anyone has any idea?
Im actually surprised that Apple don't give this option for us while they use it in quite a few places. sometimes just writing in colour is not enough to make the user understand its a button.
If you were to put a UIButton inside a UIBarButtonItem and set the backgroundColor, then you could use the cornerRadius property of it's layer:
self.button.layer.cornerRadius = 5;
In order for this to work, you need the CoreGraphics.framework and #import <QuartzCore/QuartzCore.h>
You can just provide a custom button background image with rounded corners and set it as the background image inside the storyboard.

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 do I make UITextview like Facebook comment view?

I want to make UITextview like in the Facebook comment view. How can I do it without using any external libraries?
Here is example image:
First, set the appearance of your UITextField to Alert to get the black keyboard.
Then, you only need two more views :
a black one for the background
a white one which will be the background of your text field, which you programmatically apply the following code to (don't forget to #import <QuartzCore/QuartzCore.h> first):
view.layer.cornerRadius = 10;
i have get sample code for this - here it is YIPopupTextView
What they do is use an image, that's it! They also probably expand the size of the UITextfield to make it fit the entire screen but yeah it's pretty easy. If you go into Interface Builder you can see a thing that says image. If you want to do this programmatically there is a value is textfield.background (A UIImage).
If you don't want to create an image you can create a custom UITextField subclass and use the -(void) drawInRect:(CGRect)rect function, and draw it with Quartz, and in interface builder set the UITextField class to your textfield.

Resources