Create custom UISearchBar Swift - ios

How would I create a custom search bar that looks like this:
I could also use a textfield if that would be easier. How would I create a text field that looks like this using Swift?

Create your customTextField class and inherit it from UITextField.
Make its edges round setting cornerRadius for its layer and color it gray the same way.
Add a UIImageView with on top of the search bar.
Accept touches on the view. On touchesBegan, make the textField becomeFirstResponder and make the image hidden to true.

If you want to make a custom textfield or search bar you are going to have to do it programatically. You can add the search bar or textfield to the view but in order to get a customized look, like the one in the picture below. Also, make sure that you have all the code in the ViewDidLoad() and create an outlet for the item on the view. It isn't hard to do and I'm sure you will get the desired outcome as long as you are willing to go through some trial and error!
Don't worry doing all the customization is a bunch of fun, and give a great feeling after you have solved it!
I hope this helps

Related

iOS) How to add a divider(==separator) between tabbarItems

I searched this question many times but couldn't get enough information.
So I will use UIButton or UIView to replace UITabbar for customizing issue.
I want to put divider(separator) between two tabbarItems and bottom lines like the image below
But What I made now is below:
How can I make it as I want?
I did customize many view components(UIViewcontroller, UIButton, UITextfiled,UITableViewCell,UICollectionViewCell) but I don't know how to customize tabbarItem
I'm afraid there is no specific option to set a divider in UITabBar. But you can always use a custom tab bar. You can check this out, it has a special property for seperator image:
NMBottomTabBarController for iOS
There is also another option. You may like this :) I also used it myself in one of my app. I made an image that looks like a tab bar with seperator as a background image. Then put the items on it. Easy peasy. For example check this image:
Image Link
I hope this helps.

Create custom keyboard within app not external

How am I able to create a keyboard that is already enabled in the app, or is it just buttons put next to each other to make it seem like a keyboard. Like the image below
http://i.imgur.com/qIoxR0a.png
you can use to the UIButton element or UIView with TouchBegan. But don't keyboard extension because different controller.
You can use ETCustomKeyboard which is mostly like same as you need.
And the output of that is show into below image:
You can modify this as per your need.
And HERE is one more same like that.
Hope this will help.
Create the keyboard as an ordinary UIView, and make it the inputView for your text field. There is more information in Apple's Custom Views for Data Input page.

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.

How can this bar be done in iOS?

I really like this popup with the additional functions for the selected listitem under:
But have no idea how this is done. Does anyone know how to do it or has a guide or some keywords for me?
Here is another example:
You could achieve a similar effect by adding a UISegmentedControl with <1 alpha to the view when a cell is selected - hope this helps :)
The keywords to look out for are:
UIToolBar or UISegmentedControl - both using some custom drawing or appearance modifications. Well, you could just as well create an entire custom UIView containing a bunch of UIImageView's.
Additionaly, for that shadow have a look at CALayer's shadowOffset, shadowColor, shadowOpacity, etc. ... properties.

Resources