开发者

UILabel and images in it [closed]

开发者 https://www.devze.com 2023-01-10 06:31 出处:网络
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code nece
Closed. This question needs debugging details. It is not currently accepting answers.

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. T开发者_Go百科his will help others answer the question.

Closed 3 years ago.

Improve this question

I would like to show some text with an image. But I would like the text to flow around the image. How can this be done? I've seen I can add views to a label, but I think just adding an image and then text it will not work. Can you point me to the right way please?


The best way to go about this is to create a UI Label for the side of the image, then another UI label below the image - then calculate the height of the first label a word at a time from your original text, once you have gone past the height of the UIImageView put the rest of the text in the bottom UILabel.

If you would like some example code, please email me at kendall.gelner AT kigisoftware.com (I tried to look for a way to email or DM you, but could not find one on this site).


Based on your sample image, this would be a custom object that you would have to create as a subclass of UIImage ..or you could go the easier route just make it as a view in Interface Builder that you add as a subview.

An example of subclassing UIImage would be like creating a helper method:

@interface UIImage (Labels)
- (UIImage*)toSize:(CGSize)size withLabel:(NSString *)label1 andSecondLabel:(NSString *)label2;
@end

but you would have to then implement drawing it all by yourself.

Instead, I would probably say go the route of creating a view in Interface Builder that has:

(1) UIImageView

(6) UILabels

that you can use as a subview and then you'd set them to whatever values like normal in code.


I am not sure, but Three20 is the most powerful project that I have ever seen in Iphone to support text and stylesheet. You may want to take a look

0

精彩评论

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