在我的例子中,计算一个 UILabel frame.origin.x 使其位于右侧,代码如下:
writerNameLabel.frame = CGRectMake(cell.frame.size.width - writerNameLabel.frame.size.width - 80.......)
NSLog(@" writerNameLabel frame width: %f",writerNameLabel.frame.size.width);
NSLog(@" cell frame width: %f",cell.frame.size.width);
NSLog(@" cell - writerNameLabel frame width: %f",cell.frame.size.width - writerNameLabel.frame.size.width);
NSLog(@" writerNameLabel frame x: %f",writerNameLabel.frame.origin.x);
2012-08-17 14:43:36.895 writerNameLabel frame width: 38.000000
2012-08-17 14:43:36.899 cell frame width: 320.000000
2012-08-17 14:43:36.902 cell - writerNameLabel frame width: 282.000000
2012-08-17 14:43:36.904 writerNameLabel frame x: 240.000000
----
2012-08-17 14:43:36.924 writerNameLabel frame width: 102.000000
2012-08-17 14:43:36.928 cell frame width: 320.000000
2012-08-17 14:43:36.931 cell - writerNameLabel frame width: 218.000000
2012-08-17 14:43:36.934 writerNameLabel frame x: 240.000000
问题是这
cell.frame.size.width - writerNameLabel.frame.size.width
我的计算中的一部分不起作用,它只返回值
单元格.frame.size.width - 80
, 为什么?我做错什么了吗?
请指教。谢谢。