kadmin
kadmin

Reputation: 189

iOS UILabel Formatting Tips

Does anyone have any tips or suggestions for working with labels in iOS? I am a newbie learning to develop on iOS and come from .NET world and find it extremely hard to achieve the look I need in a custom table cell I am designing.

Basically I have a custom table cell that has two labels. One for title and second one for sub title. I want my title label to hold at most two lines of text and truncate tail of longer text. For my subtitle label I want 3 lines of text. My title label will be bold and my subtitle label will have one level smaller fonts.

The only thing I am struggling with is the label heights. How to drop labels in XCode so that they accomodate two lines of text at most (and handle single lines of text gracefully) and do the same for my subtitle label.

There may be a simple solution to this but I am missing it completely. I cannot believe a simple act of dropping the most basic UI component can be so complex in iOS. I don't want to do any hacks (i.e. drop UI Views in the cell etc) if I can avoid it.

Any help will be appreciated.

Upvotes: 3

Views: 968

Answers (2)

bryanmac
bryanmac

Reputation: 39296

Here's a couple of tutorials that may help you with custom UITableViewCells:

http://useyourloaf.com/blog/2011/2/28/speeding-up-table-view-cell-loading-with-uinib.html

http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

Hope that helps

Upvotes: 1

SundayMonday
SundayMonday

Reputation: 19727

You might want to check out the default UILabels on UITableViewCell. They are textLabel and detailTextLabel respectively. Find the relevant Apple docs here.

Upvotes: 0

Related Questions