Drawing in a UITextView - iphone

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

Related

Coloring in images transparent part in imageview

The following images brown color part is transparent ,i tried coloring with the refrence http://www.edumobile.org/iphone/iphone-beginner-tutorials/digital-signature-application-in-iphone/,
Is it possible to coloring only at transparent part in the uiimage view?
The very simple solution is to have a UIView behind your UIImageView, make sure the UIImageView has a background set to Clear and then you'll be able to see what ever is in the background view through the transparent area of the image.
Check out Mike Ash’s Implementing a Flood Fill and Optimizing Flood Fill. You’ll have to swap out the NSGraphicsContext stuff for CGContext.

Change grouped UITableview border size

I know how to add a border to the tableview using:
myTableview.layer.borderColor = [UIColor redColor].CGColor
myTableview.layer.borderWidth = 3.0f;
Setting the border like this results in a square border around the bounds of the tableview not the bounds of the grouped cells in the tableview. Using a similar idea on the cells makes a square border around the bounds of the cell but not the rounded edges.
There doesnt seem to be any way of changing the seperator width on the cells either. Is it possible to make a border around a grouped tableview?
I'm not sure what you're asking. There is a cornerRadius property on CALayer in iOS 3.0 and later.
To use .layer, make sure you #import <QuartzCore/QuartzCore.h>. But UITableView does not have the border properties you are looking for, so unfortunately your code will not work.
You can however either place the UITableView on a UIImageView with an image that has a border which would be the easiest solution, or you can use CoreGraphics to draw out the border which would be a lot more work.
Thanks for the above, but Ive decided in the end to go with this method for customizing grouped tables:
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
Not as programmatic as I would have liked but it does the job brilliantly. Would like to think that this will be something Apple will make easier to implement in future XCode updates.

Mask an UITextView / UIView

Is it generally possible with an UITextView to have a mask which I can animate at runtime? Imagine a flash light effect: You have a circle mask and then move this circle around -- and only whatever is in the circle is shown of the UITextView.
Sorry to be so general, but I was only wondering if this is generally possible with an UITextView and where I would need to start to achieve such an effect. I found this: Mask UIView and this Mask text inside UITextView but neither is really about animating a mask at runtime.
Thanks!
Yes this is completely possible and easy.
It is very likely you *do not need the difficult concept of masks, as explained in the links you mention.
All you have to do is make another UIView (just do it in IB), and then move that new UIView around as you see fit.
It's just that easy. Hope it helps.

Most effective way of drawing 4 lines in an iPhone app?

basic question, but I'm unsure. Not looking for code as an answer.
I want to draw 4 short lines 1px lines on a view. What is the best way to approach this task? Options:-
Load an image of the line, then create 4 UIImageViews with it.
Create my own subclass of a UIView that draws a line in the draw rect method.
Draw elsewhere on another view, another UIImageView that has an UIImage inside it (is this possible?)
Another way?
Thanks
Ross
Simplest way is to create a UIView subclass and perform your drawing in drawRect:. See the CoreGraphics guide for details on how to draw a line.
Quick and dirty way to achieve this is to just create a UIView and set it's height (or width, depending on its orientation) to 1px, and then set a background colour and slap it onto your view as a subview.

iPhone UITextView position relative

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.