Place Image to a corner inside a Text View - ios

How i can create a view like in this image in iOS. I need to create a view so that image and the texts should be like that.

Since iOS 7 in UITextView there is textContainer property of type NSTextContainer.
You can set there exclusionPaths property which is an array of UIBezierPath objects that define your images' shapes. The text will float around those shapes. After that simply add an image view in proper place above text view.

Related

How to create a re-sizable and draggable UITextView in iOS swift?

I am creating a notes application in which user can add any number of text views and the views will have borders (like image below) so that a user can resize it.
I am thinking to create a UIBezierPath, but I don't know how to add gesture recognizers on UIBezierPath.

Swift xcode horizontal line

I wonder what the best way to create a horizontal line is?
I have a few labels / text and I would like to add a horizontal line between them. More or less like a when using twitter bootstrap.
Right now I am using a UIview and setting it as 1 in height with a black background color. But I guess this isnt the best way to do it?
That is the way to do it in iOS. UIView is the class which represent something to be shown on the screen. Every UI component is direct or indirect descendant of UIView. So, you should use UIView.
UIView is backed by CALayer to render the content to screen. You could also use CALayer, CAShapeLayer or other layer classes to create a border. But, I would not recommend to use CALayer just to show a border as it is simpler to use UIView with height of 1, on the top of that, you get some nice addition such as autolayout. If you use CALayer, you will have to set frame to layer at appropriate time when the view bounds change. It could also be tricky due to some intrinsic animation within CALayer.

UILabel linebreak on other view

I have UIView which is container for 2 views: UILabel and UIImage. Lets say that UIIlabel is same size as container. If I add UIImage at some position in container, is it possible that text is shown only in empty area where there is no image ?
Something like in word document when you place image, text breaks line whenever it intersects beggining of image. Is this possible in objective c ?
Thanks.
In iOS 7, there is a new framework named Text Kit. Working with Text Kit, you can simply add exclusion paths in UITextView which meet your question.
Here is a Text Kit Tutorial by raywenderlich and some screen shot:

Drawing an overlay on a UIView

I have a UIView that I draw a CGPath to and would like to draw an overlay onto the entire view itself, one z level above the rendered CGPath.
How is this done? Should I use a layer? I would like to draw or fill parts of the view repeatedly, so I am not sure if it might be better to use some kind of fill method. Is there a more efficient way to fill parts of the view other than drawing a new path?
I want to create the effect similar to a progress bar, extending the overlays width during runtime depending on a value.
You could use a subview (or, similarly, a sub-layer) for this. A subview of a view will appear above the content rendered in drawRect:.
If you can get away with using a UIImage background (say, one created with resizableImageWithCapInsets:), and simply changing the size of that view over time, it will likely be more efficient than redrawing in drawRect:.

iOS draw a line inside a view while drawing over existing fields

I have a view that has a bunch of labels and buttons on it with existing data. What I would like to do is to have a rounded rect with a group of labels and buttons inside them, I have about 2 groups and I would like each group to have their own rounded rect. Also I would like a line to separate the rounded rects from each other, but I heard that a label can do that just fine.
The reason I ask of this is because various tutorials and methods online specify to override the drawRect function. However, I am not sure if this will override any of my labels and buttons being rendered or their functionality.
Overriding drawRect for a view does not affect how any of its subviews are drawn, if that answers your question.
In other words, drawing a line in the background of a view will not change how labels or buttons inside that view are drawn.
However, for this effect I don't know if you need to use drawRect. If you import the QuartzCore library, you can draw a rounded rect using an ordinary view:
Just create an ordinary view behind or as a container for your buttons and labels and set it's layer.borderWidth, layer.borderColor and layer.cornerRadius properties.

Resources