UITextView text border [duplicate] - iphone

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Border around UITextView
I want to create a border around the text in a UITextView. I was able to accomplish this by creating 8 separate UITextViews and offsetting them to the 8 pixels around the center text. This looks really nice, but inputting text is severely slowed since the view has to update 9 transparent UITextViews simultaneously every time the user types something!
Is there a cleaner/faster way of accomplishing this? The effect I want is similar to photoshops 'stroke' modifier.

Can you put screenshot of what u mean by border around the text ?
If you want to have the border for UITextView try out following, this should work
#import <QuartzCore/QuartzCore.h>
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, 300, 100)];
textView.layer.borderColor = [[UIColor redColor] CGColor];
textView.layer.borderWidth = 2;

I'm not sure why my answer was deleted, perhaps because I posted the same solution on an almost identical question? You can find it there:
Bordered UITextView

Related

How to use colorWithPatternImage: with UILabel

I am trying to create a UILabel with customized text that shows the current score of a game. The customer has given me screen shots where they would like the color/pattern of the text to be like that of a wooden panel, so it looks to be brownish with darker swirls within it.
Is this even possible? I have spent an enormous amount of time scouring the web for something related to this and have found nothing concrete. One lead I followed that didn't pan out was using:
[UILabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed: #"WoodenPanel.png"]]];
It seems like there's a way to use an image and set it as the color for the text. But what results when I use this is a completely black UILabel. Is this on the right track? Or is this simply not possible?
You have to do it like this:
[labelName setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"IMAGENAME.PNG"]]];
NOT like you did:
[UILabel setTextColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"IMAGENAME.PNG"]]];
You have to put the name of the declared label instead of UILabel
Can text in UILabel have a colorWithPatternImage: assigned to it?
It does use the colorWithPatternImage though
What do you mean by it didn't pan out.
Also this is a possible duplicate of the link I just gave you.
It turns out I had actually implemented it correctly. The line of code I provided above was not an exact line out of my program, but more of a generality.
The reason I was getting a completely black font was that part of the particular image I was using was entirely black. It seems that the image isn't scaled down to fit the text and UILabel so what was being revealed was the bottom 1/5 of the image. I did not have to solve this problem as the image provided for me to implement this was a repetitive pattern throughout the image so that any part of the image would produce the desired effect of a wooden panel type color font.

Outline for UILabel text

How do I add a black outline to my white UILabel text?
One option is to set the shadow, which might not be exactly what you want, but achieves a similar effect. You can manually adjust the offset:
UILabel *myLabel = ...;
lbl.shadowColor = [UIColor whiteColor];
lbl.shadowOffset = CGSizeMake(0, -1.0);
Please note that you can also define this in Interface Builder for your UILabel.
shadow http://i.minus.com/jbiG0jVdOxJbgh.png
If this is not enough for you check out this blog post which deals with subclassing UILabel to get a glow effect:
(source: redrobotstudios.com)
Disclosure: I'm the developer of THLabel.
I've released a UILabel subclass a while ago, which allows an outline in text and other effects. You can find it here: https://github.com/tobihagemann/THLabel
I'm using Core Text and Core Graphics to achieve the effect.
For iOS5, the usual way is to use CoreGraphics to set fill/stroke and then render the graphics. It can be pretty tricky to get the alignment correct for all font sizes though.
I recommend looking at my solution here. You can either use it straight (it has diffuse shadows as well), or simply pick out the code that does the outline. For iOS6 there is a neater (smaller) solution which works even better. Look here.
I am sure this code will solve your problem.
In KSLabel.m class see this line of code
// Outline color
self.textColor = [UIColor whiteColor];
change it to
self.textColor = [UIColor blackColor];
and you will see the black border of the text.

How do I animate a UILabel's color? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to animate the background color of a UILabel?
I'm pretty new to animating things on iOS and have a basic question.
I have a UILabel that I want to briefly change the color of. Basically, inside of cellForRowAtIndexPath: I am reloading my cell's every 15 seconds or so. If a certain cell meet's a requirement, I want to briefly change the label's color and animate it to fade off back to it's original color.
Pop on, fade out.
Any tips would be amazing. Thanks guys.
This isn't the brightest solution, but it might get you to what you need: Create an identical, new UILabel with the same frame, font, etc... but with a different color. Use the animatable "alpha" property to fade your old color out and it will seem as if the underlaying label's color is being transitioned in.

How to type a text in imgeview. Right now sucessfully drawing using mouse

How to type a text in imgeview... right now successfully drawing using mouse. I need to type text in same image view using keyboard...
Try superimposing a UITextView on top of your UIImageView and set appropriate frames for both so that the text appears until where you want it to appear.
Set this property for your UITextView
myTextView.backgroundColor = [UIColor clearColor];
myTextView.textColor = [UIColor redColor]; //or whatever color you like based on the background image in your UIImageView.
Of course you will have to take care of the scrolling when the keyboard comes up after the UITextView becomes active.
If you want more assistance, please elaborate upon your question and your need.

Want to make a text editor.. how to apply background image to TextView? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
UITextView background image
I want to add a background image to a textview. Can it be done through the interface editor?
If not, what will be the code required to do so?
I want the text to scroll with the background image as the number of lines with text increase.
Well I found the following way, using patternImage. Multiple lines can be made, pattern will contain a single line :)
textView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed: #"line.png"]];
Just put UIImageView with your desired image, and, above that, use textview with ClearColor Background.