任何人都有苹果在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. Solr:没有显式设置默认值的字段默认值是什么?
- 2. 设置MacVim默认字体
- 3. 从CKEditor中的样式菜单中设置默认样式
- 4. 在C#中设置默认字体
- 5. 在NSTextView中设置默认字体
- 6. Eclipse在Mac OS X上使用的默认字体是什么?
- 7. flex使用的默认字体是什么?
- 8. 在Android中使用默认字体样式
- 9. Android中应用栏文本的默认字体是什么?
- 10. 提交按钮字体 - 它是什么? (浏览器默认样式)
- 11. 设置默认的字体与插件
- 12. 按资源设置默认样式
- 13. 将文本设置为默认样式
- 14. toolStripComboBox设置字体样式?
- 15. Hive中的默认模式是什么?
- 16. 什么是为所有JComponents设置默认设置的便捷方式
- 17. R的plot()中的默认字体是什么?
- 18. 设置默认字体主窗口pyside
- 19. 为SWT Shell设置默认字体
- 20. 如何设置默认字体NSAttributedString
- 21. CKEditor 4 - 如何设置默认字体?
- 22. UIViewController默认标题字体设置
- 23. 实体框架中的默认模式是什么?
- 24. 什么是WPF应用程序的默认字体系列?
- 25. Android中的默认字体系列是什么?
- 26. Android中的默认字体特征是什么?
- 27. 什么是Visual Studio 2013中的默认字体
- 28. 什么是PHP GD库中使用的默认字体的名称?
- 29. 为什么更改字体大小会混淆默认的HTML按钮样式?
- 30. Tensorflow中设备放置的默认策略是什么?
检查我对类似的问题的答案: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