夏树正茂

花有重开日,人无再少年.

Xcode控制台打印CGRect

| Comments

在用Xcode调试开发的时候,我们经常需要在控制台打印某个视图的frame,以前的时候相当麻烦,但是从Xcode6.3以后,打印frame变得很简单:

1
2
3
4
5
6
7
8
// Before
(lldb) p (CGRect) [self frame]
(CGRect) $0 = (origin = (x = 0, y = 0), size = (width = 50, height = 100))
 
// After
(lldb) expr @import UIKit
(lldb) p self.frame
(CGRect) $1 = (origin = (x = 0, y = 0), size = (width = 50, height = 100))

Comments