i got a news page (a view) at my application and it has news' image and text. Text is in a UITextView and i want my text to start next to image and when the image ends continue from the down of the image, like the text is surrounding the image. i tried autoResizingMask but as i ve understood it is for the relations between subview and superview so it didnt work. Is there any way to do it ?
Thanx in advance
AFAIK, UITextView doesn't support wrapping around other views. You can:
Split the text into two UITextViews
Use a UIWebView
Do your own drawing using NSString's drawInRect or drawAtPoint methods.
Related
I am working in an app in which I need to give feature like Notes App in iphone. as shown in first screen shot , initially , notes leaves a tab before the content starts, I also wanted to do the same and for that when I set Left Content inset (of UITextView) by 25 , it shows like in screenshot 2, here you may see the image also gets shifted. I have set image as background. I don't know how to solve this problem.
I also tried by adding image as subview of UITextview but it won't repeat the lines, while scrolling (image of lines) like notes app.
I'm setting the background of Textview by following code.
[textView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"line_image.png"]]];
Please tell me if I am going wrong or any extra effort needed to get desired output.
Thanks
UITextView is UIScrollView subclass so all relevant delegate method are available for you (e.g. scrollViewDidScroll:) - you can adjust your custom background in that method.
There's very nice post on Dr.Touch blog about recreating Notes app interface - you can get general idea about how it is done from it. Basically what is done there is adding custom view that draws background behind the text view and adjust it in text view's delegate methods and also using KVO on its 'contentSize' property.
#Dinesh gave nice solution but it doesn't sound to be generic as I want to use image of lines instead of drawing them. Image has some special effects that can not be achieved by drawing. So to solve it I created a table view below the textview keeping textview's background transparent. Now just added the image of line to my tableview's custom cell and set content offset of UItableview same as of the scrollview (subview of text view ,refering to the answer of #Vladimir ) .
And used the following code to scroll my tableview with scrolling the textview and got the desired output.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
tableView.contentOffset =scrollView.contentOffset;
}
Keeping my tableview's number of rows at a very large number.
PS: instead of setting the content inset of textview, i set its frame's X position and decreased the width relaively.
I want my UITextView to show text but not have the text be as wide as the screen. The problem I face with this, however, is that I want the scrollbar to be in the position it's in now. I'm unsure how to do this. Here's an image of the text i want bringing in, to show you what i mean a bit more clearly:
You can customize the position of the text using the contentInset, contentOffset and contentSize properties of UIScrollView (which is the superclass of UITextView).
I have a project where I let the user draw on the screen of the iPhone (signature box). It works great... prints to a specific label printer (Zebra gx420d). My question is as follows: Can I have a UILabel field be part of the "Image" that is drawn? It is visible on screen, but doesn't print.
Any help would be appreciated!
Just make sure the label and your custom view subclass that draws the signature are both subviews of a common superview. Then invoke print on the common superview, and both of them (actually all subviews) will be part of the printed image.
You need to draw the text into an image graphics context.
This question may help: How do I use the NSString draw functionality to create a UIImage from text
I'm new in Iphone. I have an UITextView inside a UIImageView . Now I need to dynamically resize the UIImageView so that its textview also change its size dynamically. Moreover I can move this UIImageView with UITextView around the screen. If any one knows this using UIGuesture please help me.
Any help would be appreciated
If you are looking at resizing the UIImageView object, look at the UIPinchGestureRecognizer. It will have a property called scale that you can use to change its size.
As for the UITextView object that is the subview, you can look at autoresizingMask property inherited from UIView. Set it appropriately so that the text view scales in response to its super view.
For moving the image view, you can use the UIPanGestureRecognizer. You can get the translation using translationInView:. Use this to modify the center of the image view object. This should move the image view as you drag your finger around.
I hope you've gone through the guide. Let us know if you face problems implementing this and put some code so that we can guide you in the right direction.
I'm trying to make a UITextView look like a piece of paper with the red lines, margins, etc.
I haven't found anything that would allow me to use graphics in a UITextView and I can't use a UITextField because I need to allow multiple lines...
I've tried drawing in a normal UIView and then trying to blend that with the UITextView but that apparently wasn't the right approach.
Any help would be great. Thanks!
Do you just need a background image? This thread may help:
UITextView background image