views:

74

answers:

2

Basically I want to copy the behavior in iPhone's Calendar where the day of week (Mon, Tue, Wed) is on the left side of the table's section header (left justified) while the formatted date (Apr 1, 2010, May 1, 2010) based on locale is on the right side of the table's section header (right justified).

I was thinking of inserting a variable amount of space in between the day of week and formatted date but I first need to know the actual space consumed by the text on both sides to figure out how much space to add.

Hope to hear your thoughts on this.

Thanks.

+1  A: 

There're some additions made in UIKit to NSString class, among them functions allowing to determine string size when drawing with specific font. See this function in docs for a start:

- (CGSize)sizeWithFont:(UIFont *)font
Vladimir
This is great, thanks! I guess I didn't look hard enough in the docs... :)
paul_sns
A: 

Maybe you could create a temporary UILabel, set your date string as text of the label and then get the width of the label through the frame property (--> label.size.width).

schaechtele