How do I make UITextview like Facebook comment view? - ios

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.

Related

Create custom UISearchBar Swift

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

How can I increase/decrease the brightness of the image in iOS?

I've an image , I want to increase/decrease its brightness by using a UISlider? How can I do it?
Is there any default method are available for this? If yes, please tell me..
Thanks!
If you don't want to use the link and want to code a custom solution try this:
In your Storyboard add an imageView with the image
Add a view that has a white background color
Add a view with a black background color
Add a slider and make sure they aren't in each others views!
Now use CNTRL + click to create your properties in the .M file
Create the method for the slider by CNTRL + clicking below the viewDidLoad method and name the method something like sliderChanged:
Change (id)sender to (UISlider *)sender
Last thing to do, fill the method body with this!
these are screenshots from the custom brightness app you just made:

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.

iOS modify the layer of a UIElements that are created with IB

In my app, I would like to create a custom UIElement, in my case a UITextView with rounded corners and border color and everything. however I can only do it if I create the UITextView from code and add it to a view with the addSubView method.
That's not too elegant, plus it fails during the unit tests as well.
Is there a way how I can create my UITextView with using Interface Bulder and still being able to modify its layer property?
Any help is very much appreciated.
If you create an IBOutlet by ctrl-dragging from the nib or storyboard to your .h file, you can access your graphical element as usual with something like myTextView.layer.cornerRadius = 5.0;.

Resources