iphone - How to display an array of UILabels? -


I have a list of items that I would like to show in a UITableViewCell. Right now, I'm just using a cell. With comma separated from each value with text lab, but I want to make a bit more dynamic.

How do I achieve something like this? alt text

Will it be an array of UILabels with boundaries and radius on those bounds? ?

Thank you for your thoughts.

This is the quick and easy way possible. It's based on the code that you can get.

Note that you need to add Quartzcore framework to your project and include it in the file where you write this code!

Every UIView can be found on the CALayer of UIView with you backed by a CALayer. Since UILB is a UIUV, you can get its backing layer in this way. Once you have a backing layer, you can set its background color, corners, radios, border colors, and border width properties. You should make the round effect.

To get a focused effect, try setting the text of UILabel. Again, you can try to set the frame of the UALBL based on size, or maybe the calling size On the base on the string you put on the string.

There is some quick, completely unwanted code to get you started. / P>

Assume that you've initialized a UIFont (Enter whatever size you want for the font).

  labelFont = [UIFont systemFontOfSize: 14];  

Then, for each label, set it up. I'm assuming you have pulled the text from an array and put it in a variable called "text". X_PADDING and Y_PADDING are how much distance you want around the label's text. XLOC and YLOC are variables that you are using to keep track of the position of X and Y, on which you want to keep the labels. You may increase xLoc based on text size + X_PADDING + LABEL_SPACING or something else (where you define LABEL_SPACING):

  CGSize text size = [text size WithFont: labelFont]; CGRTF frame = CGRactMake (XLok, YLOC, Textas.Width + XPDADIID, TextusHyight + Y_PinningAud); UILBL * label = [[Uiblal alloc] initwithframe: frame]; Label.text = text; Label.textAlignment = UITextAlignmentCenter; CALayer * layer = label.layer; Layer. Mask tubons = Yes; Layer CornerRadia = 7.0; // which works for you layer. BorderWidth = 1.0; Layer.borderColor = [[UIColor redColor] .CGColor; Layer.backgroundColor = [UIColor blueColor] .CGColor; // Add layer to your supervision [yourSuperview addSubview: label];  

I hope this helps you get started.


Comments