Is it possible to change color of single word in UITextView and UITextField

Yes you need to use NSAttributedString for that, find the RunningAppHere. Scan through the word and find the range of your word and change its color. EDIT: – (IBAction)colorWord:(id)sender { NSMutableAttributedString * string = [[NSMutableAttributedString alloc]initWithString:self.text.text]; NSArray *words=[self.text.text componentsSeparatedByString:@” “]; for (NSString *word in words) { if ([word hasPrefix:@”@”]) { NSRange range=[self.text.text rangeOfString:word]; [string addAttribute:NSForegroundColorAttributeName … Read more

UITextView ruled line background but wrong line height

You should try and draw your lines programmatically rather than using an image. Here’s some sample code of how you could accomplish that. You can subclass UITextView and override it’s drawRect: method. NoteView.h #import <UIKit/UIKit.h> @interface NoteView : UITextView <UITextViewDelegate> { } @end NoteView.m #import “NoteView.h” @implementation NoteView – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; … Read more

how to know when text is pasted into UITextView

Here is what i use to detect paste events in UITextView: // Set this class to be the delegate of the UITextView. Now when a user will paste a text in that textview, this delegate will be called. -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { // Here we check if the replacement text is equal to … Read more

How do I size a UITextView to its content on iOS 7?

I favor this minimal code change: Just add these two lines after addSubview and before grabbing the height of the frame … [scrollView1 addSubview: myTextView]; [myTextView sizeToFit]; //added [myTextView layoutIfNeeded]; //added CGRect frame = myTextView.frame; … This is tested backwards compatible with iOS 6. NOTE that it shrink-wraps the width. If you’re just interested in … Read more

How to style UITextview to like Rounded Rect text field?

There is no implicit style that you have to choose, it involves writing a bit of code using the QuartzCore framework: //first, you #import <QuartzCore/QuartzCore.h> //….. //Here I add a UITextView in code, it will work if it’s added in IB too UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(50, 220, 200, 100)]; //To make the border … Read more