0

I don't know a lot about modifying the frame of an object I am using in a View and this is why I am coming to you with the following problem.How do you make your textview's frame look like a speech bubble

Is it a way of modifying only the frame or do I need to create a custom textview class?

I only want to add the little triangle on the left/right triangle to the frame

The final result should be this!

enter image description here

tudoricc
  • 709
  • 1
  • 12
  • 31

3 Answers3

2

I would simply create a UIImageView with the textfields frame (or similar) and place it below it. The trick here is to use a stretchable image for the image view. Or you could generate a UIBezierPath depending on the textfields frame and give it a border and fill color.

freshking
  • 1,824
  • 18
  • 31
  • by below you mean to place the textview on top of the image? – tudoricc Sep 15 '14 at 09:00
  • Yes exactly. check out this link: http://stackoverflow.com/questions/11196112/speech-bubble-in-ios-sdk-using-objective-c – freshking Sep 15 '14 at 09:05
  • I did as you said.but now I am working on makeing the textview fit the whole text you inputed thus increasing the height of the image and of the textview.so do i keep the image stretched? – tudoricc Sep 15 '14 at 09:20
1

To be dynamic, I would make a custom view for this which holds a UITextView and the arrow icon as a UIImageView. This can be placed at the correct position next to the text view.

To make the rounded corners, you can set the layer.cornerRadius on the UITextView. Thus you are independent of the text length.

Sebastian Wramba
  • 10,087
  • 8
  • 41
  • 58
0

Custom textview class is not necessary.

If left/right triangle position is fixed, changing the textview frame is sufficient. If not,change the frame of the Textview depending on the text content size, parallely change the frame of the triangle accordingly .