Anyone have a listing of the default font settings Apple uses in the UITableViewCells, UILabel etc? Also the positioning information for the textLabel in the UITableViewCell both grouped and plain would be fantastic.
Are you familiar with the debugger? It knows all. To get access to the layout, try the following in gdb.
I set the breakpoint in - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
which is called right before the cell is displayed
(note: there's a background image in my cell)
(gdb) po cell
<UITableViewCell: 0x59e9920; frame = (0 66; 320 44); text = '396 Studio'; autoresize = W; layer = <CALayer: 0x59e9a00>>
(gdb) po [cell subviews]
<__NSArrayM 0x4eaf730>(
<UIImageView: 0x59ea660; frame = (0 0; 320 100); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x59ea690>>,
<UITableViewCellContentView: 0x59e9eb0; frame = (9 0; 302 44); layer = <CALayer: 0x59ea070>>
)
(gdb) po [[[cell subviews] objectAtIndex:1] subviews]
<__NSArrayM 0x4eaf700>(
<UILabel: 0x59e9170; frame = (0 0; 0 0); text = '396 Studio'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x59e91e0>>,
<UITableViewLabel: 0x59e65c0; frame = (0 0; 0 0); text = 'Houston'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x59e6690>>
)
(gdb) po [0x59e9170 font]
<UICFFont: 0x5e12610> font-family: "Helvetica"; font-weight: bold; font-style: normal; font-size: 0px
(gdb) p (CGRect)[cell frame]
$1 = {
origin = {
x = 0,
y = 66
},
size = {
width = 320,
height = 44
}
}
po
= print object
p
= print, but you have to cast the value to the type you know it is
no property access cell.frame
- use objective-c methods [cell frame]
Also, here is a 4 year old, but still useful article on iPhone fonts: daring fireball.
I subclassed a UITableViewCell to get these values. Heres my code:
dlog(@"%@",self.detailTextLabel.font);
dlog(@"%@",self.detailTextLabel.bounds);
dlog(@"%f",self.detailTextLabel.frame.size.height);
dlog(@"%f",self.detailTextLabel.frame.size.width);
dlog(@"%f",self.detailTextLabel.frame.origin.x);
dlog(@"%f",self.detailTextLabel.frame.origin.y);
dlog(@"%@",self.detailTextLabel.textColor);
output:
2012-06-06 15:01:08.384 myapp[1007:f803] <mytablecell.m:(48)> <UICFFont: 0x68c8b20> font-family: "Helvetica"; font-weight: normal; font-style: normal; font-size: 14px//remember the text will shrink before hiding some with the "..." but this is default
2012-06-06 15:01:08.387 myapp[1007:f803] <mytablecell.m:(49)> (null)
2012-06-06 15:01:08.389 myapp[1007:f803] <mytablecell.m:(50)> 18.000000
2012-06-06 15:01:08.391 myapp[1007:f803] <mytablecell.m:(51)> 280.000000//its 284 if there is no accessory view(such as the checkmark I had in there when this ran)
2012-06-06 15:01:08.393 myapp[1007:f803] <mytablecell.m:(52)> 10.000000
2012-06-06 15:01:08.396 myapp[1007:f803] <mytablecell.m:(53)> 24.000000
2012-06-06 15:01:08.398 myapp[1007:f803] <mytablecell.m:(54)> UIDeviceRGBColorSpace 0.5 0.5 0.5 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With