开发者

iphone: Text around an image

Is it possible to have text go around an image ? like in the pict开发者_运维问答ure? alt text http://andyj.be/image.png


I'm going to go with UIWebView as well. You can probably make a guess as to what they're doing by scrolling the page up and down. In my experience, a UIWebView scrolls more sluggishly compared to a UIScrollView, and comes to a stop more quickly.

If you really have your heart set on using a UIScrollView to make this effect, you can use this method:

CGSize size = [textView.text sizeWithFont:textView.font
constrainedToSize:CGSizeMake(frame.size.width, 9999)
lineBreakMode:UILineBreakModeWordWrap];

Get your text and put it in a loop. With each iteration of the loop, chop a word off the end. Compare the size from the method above to the frame size you want and if it's taller, go through the loop again. When the size.height is smaller than what you want, you know how much text to add into the top text view (to the right of the image). Add the rest of the text into the text view under the image, using the above method to size it's frame.


I'd be willing to bet that the view in your screenshot is a UIWebView. If you're willing to use UIWebView, then sure you can! Otherwise, I'm not aware of any built-in control that'll allow this to be done easily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜