任何人都有苹果在UITableViewCells,UILabel等中使用的默认字体设置列表?同样,UITableViewCell中textLabel的定位信息都是分组的,并且非常棒。UITableViewCell样式中使用的默认字体设置是什么?
8
A
回答
12
您是否熟悉调试器?它知道所有。要访问布局,请在gdb中尝试以下内容。
我设置的断点在- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
显示单元右侧前
被称为(注:有一个背景图像在我的细胞)
(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
=打印对象 p
=打印,但您必须将值转换为您知道的类型
无资产访问cell.frame
- 使用objective-c方法[cell frame]
此外,这是一个4岁,但仍然有用的iPhone字体文章:daring fireball。
7
我创建了一个UITableViewCell的子类来获取这些值。我的继承人代码:
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);
输出:
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
相关问题
- 1. HTML中的默认字体是什么
- 2. Solr:没有显式设置默认值的字段默认值是什么?
- 3. 什么是默认的HTML字体?
- 4. Matlab设置默认字体
- 5. 设置MacVim默认字体
- 6. 什么是jQueryMobile默认字体?
- 7. 什么是默认字体系列?
- 8. 什么是MonoDevelop默认字体?
- 9. 为什么Compass/Scss设置列表样式:默认没有?
- 10. 从CKEditor中的样式菜单中设置默认样式
- 11. 为什么不应用默认样式?
- 12. Eclipse在Mac OS X上使用的默认字体是什么?
- 13. flex使用的默认字体是什么?
- 14. 什么是WPF MS Ribbon控件上使用的默认字体?
- 15. 在gvim中设置默认字体
- 16. 在NSTextView中设置默认字体
- 17. 在JEditorPane中设置默认字体
- 18. 在C#中设置默认字体
- 19. IDWriteTextLayout使用的默认印刷设置是什么?
- 20. 在Android中使用默认字体样式
- 21. Android中应用栏文本的默认字体是什么?
- 22. 提交按钮字体 - 它是什么? (浏览器默认样式)
- 23. 如何设置默认的UITableViewCell高度?
- 24. 如何使用Setters在XAML中设置默认样式?
- 25. 将文本设置为默认样式
- 26. 按资源设置默认样式
- 27. 将默认样式设置为listviewitem
- 28. 如何设置NSTextView的默认字体?
- 29. 如何设置phantomjs的默认字体?
- 30. 设置默认的字体与插件
检查我对类似的问题的答案:http://stackoverflow.com/questions/4775107/uitableviewcellstylesubtitle-font-size/4777507#4777507。 – Vladimir 2011-03-02 23:10:30
检查标签定位只需创建示例项目,并检查哪些单元格的标签框架。它们可能取决于许多因素(例如单元大小),并且可能在未来可能会发生变化,因此无论如何您都不应该依赖这些值。 – Vladimir 2011-03-02 23:13:00
@Vladimir谢谢你的回答。你用来检查UIViews帧的代码是什么?你知道是否有类似的电话会告诉你字体的颜色和大小吗? – Aaronium112 2011-03-03 15:56:51