plspl
plspl

Reputation: 3

speech bubbles like in comics for iphone

I am new to iphone application development. I am building an iphone app where the user needs to be able to add speech bubbles (think comics) over existing images. I have some questions on how to implement this,

Thanks,

Update -

Found a similar example on this site where we move/resize a UIView - http://www.switchonthecode.com/tutorials/creating-basic-animations-on-iphone

Upvotes: 0

Views: 2057

Answers (2)

james_womack
james_womack

Reputation: 10296

I would use a transparent UIView with a UIImageView containing the bubble and a UITextView set editable.

Use this to resize the text view whenever the text view changed notification is sent: CGRect frame = textview.frame; frame.size.height = textview.contentSize.height; Textview.frame = frame;

Subclass the UIView and use touchesbegan and touchesmoved to determine where to move the view as its being dragged.

sizewithfont: constrainedtosize: linebreakmode is the string size method

How to save a UIImage of this layout to the photo album:

CGRect screenRect = CGRectMake(0, 0, 320, 416); // change this as necessary
UIGraphicsBeginImageContext(screenRect.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil);

Upvotes: 2

Hetal Vora
Hetal Vora

Reputation: 3361

I had implemented this kind of interface by using a UITableview, setting background of the UITableview cell to the speech bubble image. I used sizewithfont: constrainedtosize: linebreakmode to get the width and height of the text content and accordingly set the frame of my tableview cell. Since this was a chat application, the user would type in the text in a textfield at the bottom of the view and click on a button next to it and the text would appear in a callout in the tableview.

But in your case, since you need to move the bubble around when you touch it, Cirrostratus's method seems appropriate.

Upvotes: 0

Related Questions